It's all about the answers!

Ask a question

Issue with the edit work item when it has read only attribute


yaswanth palem (112) | asked Aug 02 '18, 10:11 a.m.
Hello All,

Can anyone please help on the below scenario?

I have created a customized attribute Demand ID for work item with read only setting.


When I am creating the work item the Demand ID is generating correctly, but when I am trying to edit the work item.
It is showing the below error.

"CRRTC0299E: The work item with the ID 2028 cannot be saved because an attempt was made to change the attributes '[Demand ID]' which are not modifiable."

I want the Demand ID attribute with read only setting, and I have to edit the work item.

Below is the script which I have written:

dojo.provide("org.example.workitems.providers.ZScript");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date.stamp");
dojo.require("dojo.date.locale");
(function() {
var WorkItemAttributes=com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("org.example.workitems.providers.ZScript", null, {

getValue: function(attributeId, workItem, configuration) {
  var currentDate = new Date(); 
    console.log("current Date = " +currentDate); 

var year = dojo.date.locale.format(new Date(currentDate), {datePattern: "yyyy" , selector: "date"});
console.log(" Current year == "+year);
var demandID = workItem.getValue(WorkItemAttributes.DEMAND_ID);
console.log("demandID = " +demandID); 

var internalID=workItem.getValue(WorkItemAttributes.ID);
console.log("internalID === " +internalID); 
    
var state=workItem.getValue(WorkItemAttributes.STATE);
console.log("Status is:"+state)

if(demandID === "null"){                    
           console.log("Answer is CR2018- "+internalID);
   return "CR"+year+"-"+internalID;
}else{
  return false;
}
   
    }
});
})();


Regards,
Yaswanth

One answer



permanent link
Ralph Schoon (63.3k33646) | answered Aug 02 '18, 12:59 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

This is a calculated value.
From a script perspective, this does not make any sense:
  return "CR"+year+"-"+internalID;

}else{
  return false;
}
If the attribute is for a string you would want to always return a string. Return the old value or "" and not false.
Otherwise, if you make the attribute read only that it might not be possible to write the value. You can look at making the attribute presentation read only. I have no time to test anything.

 



Comments
yaswanth palem commented Aug 07 '18, 3:01 a.m.

Hi Ralph,


Yes I have tried with return "" as well, but I am unable to edit the work item because the attribute Deamd ID is selected the read-only checkbox. 

Thank you..


Ralph Schoon commented Aug 07 '18, 4:32 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

As I already said, if a read only attribute is also read only for attribute customization (which I find irritating, as I think this was not the case in the past), you can make the attribute read only in the editor presentations.


yaswanth palem commented Aug 21 '18, 9:28 a.m.

 Hi,


Editor presentation is for displaying here I am facing issue with handling script.
I am unable to save the work item because of customized attribute "Demand ID" is read only.

Thank you.. 

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.