Disable Title and description editing
I have been playing around with forms and came across a strange issue.
I want to disable the editing of the title and description fields in the IR and SR forms. I have done this by copying the incident.js to CustomScripts and changing the property to read-only. This works as expected...
The problem I have is that when I create a new Incident via the drawer -> New -> Work Item -> Incident -> From Template the title and description cant be edited and thus the Incident cant be logged.
The reason I want to do it via the templates is that I cant create templates for every possible scenario and the quick create is not as quick as the name implies ;-) The analysts have to fill in all the fields in the quick create and it is time consuming.
If someone can suggest an alternate way to do this it will be much appreciated.
Regards
Gerhard
Best Answers
-
Konstantin_Slavin-Bo Customer Ninja IT Monkey ✭✭✭✭Roland_Kind said:you could check the html title to see, if the workitem is "new" or not and if you are applying this on the correct workitem type ..
pageForm
has anewWI
property5 -
Gerhard_Goossens Customer Advanced IT Monkey ✭✭✭Ok, got it figured out ;-)
app.custom.formTasks.add('Incident', null, function (formObj, viewModel) { //Form Ready formObj.boundReady(function () { // Get new work item status var newWorkItem = pageForm.newWI.toString(); // Check if it is a new work item if ( newWorkItem == "false") { // Assign properties to disable var disableRequestedWI = document.getElementsByName('RequestedWorkItem')[0]; var disableTitle = document.getElementsByName('Title')[0]; var disableDescription = document.getElementsByName('Description')[0]; // Disable properties disableRequestedWI.setAttribute("disabled", "true"); disableTitle.setAttribute("disabled", "true"); disableDescription.setAttribute("disabled", "true"); }; }); });
So this will disable the textboxes for the user who requested the WorkItem. the Title and Description. If the work item is not new. ie created from the drawer New -> Work Item ...
0
Answers
Hi,
maybe an alternate approach could be (instead of modifying the incident.js):
var OptionsDictionary= {'Title': '', 'Description' : ''}; // definition of "object labels" which should be disabled
qcontainer=$('.form-group'); //
for (i = 0; i < qcontainer.length; i++) {
prompt=qcontainer[i].children[0].htmlFor
if (prompt in OptionsDictionary) // true if "key" exist in object
{
qcontainer[i].children[1].disabled=true;
qcontainer[i].children[2].disabled=true;
}
}
you could check the html title to see, if the workitem is "new" or not and if you are applying this on the correct workitem type ...
hope this helps
Roland
pageForm
has anewWI
propertyI suspect that the function gets overwritten by the incident.js after load
function disableTitle() {
if (pageForm.newWI=false) {
var setTitle = document.getElementsByName('Title')[0];
setTitle.setAttribute("readonly", "true");
}
}
Hi,
for testing I have it implemented in a function like that:
$(document).ready(function ()
{
setTimeout(function () { // wait some time ...
var OptionsDictionary= {'Title': '', 'Description' : ''}; // definition of "labels for objects" which should be disabled
qcontainer=$('.form-group'); //
for (i = 0; i < qcontainer.length; i++) {
prompt=qcontainer[i].children[0].htmlFor
if (prompt in OptionsDictionary) // true if "key" exist in object
{
qcontainer[i].children[1].disabled=true;
qcontainer[i].children[2].disabled=true;
}
}
}, 2000);
});
I'm currently trying to figure out how to check for pageForm.newWI=false and only then disable the Title, Description and affectedUser.
Hi,
$(document).ready(function ()
{
if (pageForm.newWI==false)
{
setTimeout(function () { // wait some time ...
var OptionsDictionary= {'Title': '', 'Description' : ''}; // definition of "labels for objects" which should be disabled
qcontainer=$('.form-group'); //
for (i = 0; i < qcontainer.length; i++) {
prompt=qcontainer[i].children[0].htmlFor
if (prompt in OptionsDictionary) // true if "key" exist in object
{
qcontainer[i].children[1].disabled=true;
qcontainer[i].children[2].disabled=true;
}
}
}, 2000);
}
});
regards
So this will disable the textboxes for the user who requested the WorkItem. the Title and Description. If the work item is not new. ie created from the drawer New -> Work Item ...