It's all about the answers!

Ask a question

Why do a get an error that says "attribute is not modifiable" when i change the state of the work item after populating a date/time field


Ramona Pillay (111) | asked Jun 11 '20, 6:54 a.m.

 heres my use case:

I created a field called "High level start Date". I am using dojo script to calculate the high level start date when the workflow state = "HL in progress"
I then configured the field to be read only in all states accept "HLIA in progress"

So the script works fine and populates the date/time to be current date/time.

The minute i change the state to the next workflow state, it says this "High level start Date is not modifable". I am not even trying to do anything at the next stage. I tried it on a non date time field and it works fine to enable and disable the fields etc. Is there something i am doing wrong in my code. I tried various ways to write the script. declaring variables before the if statement, and even in the if statement.

I also tried using a script enable and disable the field and i get the same error. Please can you advise what i could be doing wrong.

dojo.provide("org.example.workitems.providers.CalcHLIAStart");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");


var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
//var Iteration= com.ibm.team.process.Iteration

(function() {
dojo.declare("org.example.workitems.providers.CalcHLIAStart", null, {

    getValue: function(attributeId, workItem, configuration) {
   

      if (workItem.getLabel(WorkItemAttributes.STATE) == "HLIA/RFP Review In progress")
      {
var HLIAbegin = dojo.date.stamp.toISOString(new Date(),{zulu:true}); 
return HLIAbegin;
}
return HLIAbegin;
    }
});
})();


//Ramona Pillay

2 answers



permanent link
Ralph Schoon (63.1k33646) | answered Jun 15 '20, 3:53 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I can't debug your script. The only changes I did below is: Get the data value of the attribute (might be unassigned or whatever) and initialize the return value with it. So the value is always available. Then overwrite its value if needed

dojo.provide("org.example.workitems.providers.CalcHLIAStart");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");

var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
//var Iteration= com.ibm.team.process.Iteration

(function() {
dojo.declare("org.example.workitems.providers.CalcHLIAStart", null, {

    getValue: function(attributeId, workItem, configuration) {
    var HLIAbegin =workItem.getValue("TheAttributeIWantToSetTheDate")   
    if (workItem.getLabel(WorkItemAttributes.STATE) == "HLIA/RFP Review In progress")
    {
       HLIAbegin = dojo.date.stamp.toISOString(new Date(),{milliseconds:true, zulu:true}); 
       return HLIAbegin;
    }
    return HLIAbegin;
    }
});
})(); 

Consider reading https://jazz.net/library/article/1093 especially the last labs hints to where the Log files are and how to debug scripts.

permanent link
Ralph Schoon (63.1k33646) | answered Jun 15 '20, 2:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

This script seems to be syntactically incorrect. The outer return statement value is undefined.


Comments
Ramona Pillay commented Jun 15 '20, 3:13 a.m.

 Hi Ralph, So i also tried where i assigned HLIAbegin to "Unassigned". I still experienced the same issue. Can you possible show me on the above script how you would change it to make it correct. I have tried so many different combinations and ways of writing the script and all still gave me the same issue.

I would really appreciate if you can correct the script for me so i can use it as a standard going forward.

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.