It's all about the answers!

Ask a question

Attribute customization condition for precondition


Timothy Distel (7317) | asked Jun 13 '19, 4:27 p.m.

 Hello,


I am using CLM Suite 6.0.6.

Following the direction from this post:


I've generated a script based on the example provided here (as a reference from the above link):


I've followed all of the steps to enforce this condition with a precondition, however it seems to not be functional. Since I'm not proficient in scripting, I assume the issue is with the script I've generated. The demo script in the link above is only slightly different conceptually from how I want my condition to function, so I adopted the structure. Here is my script:



dojo.provide("org.example.workitems.providers.WorkActivityToBuild");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
 
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
 
dojo.declare("org.example.workitems.providers.WorkActivityToBuild", null, {
 
matches: function(workItem, configuration) {
var atb =  workItem.getValue(WorkItemAttributes.AssignedWorkActivity);
return (atb === "AssignedWorkActivity.literal.l4");
      }    });  })();



The condition "WorkActivityToBuild" needs to resolve to a true or false based on whether or not the "AssignedWorkActivity" attribute is set to the "Assigned To Build" ("AssignedWorkActivity.literal.l4") literal.

Any help would be greatly appreciated.

Accepted answer


permanent link
Davyd Norris (1.0k7) | answered Jun 13 '19, 10:14 p.m.
WorkItemAttributes gives you the names of most of the built in RTC attributes - it doesn't give you the names of your own custom ones, so the line:

var atb =  workItem.getValue(WorkItemAttributes.AssignedWorkActivity);

is not going to return anything useful. Try changing to:

var atb =  workItem.getValue("AssignedWorkActivity");

assuming that's the id of your own custom attribute.
Timothy Distel selected this answer as the correct answer

Comments
Timothy Distel commented Jun 14 '19, 6:34 a.m. | edited Jun 14 '19, 6:37 a.m.

 Thank you davyd!


Timothy Distel commented Jun 14 '19, 6:39 a.m.

 Are there any resources you would recommend to help with learning this type of scripting aside from this part of the wiki?


Timothy Distel commented Jun 14 '19, 7:31 a.m.

 Davyd,


Changing that line made the script require the attribute, but the prevent save is not recognizing that a value is set in the dependent attribute. In other words when I set the literal, (defined in the script) an attribute is required. I populate that attribute, but the work item will still not allow a save. Can you provide insight here?


Timothy Distel commented Jun 14 '19, 7:47 a.m.

 Nevermind, there was attribute confusion based on IDs. Thank you again!


Ralph Schoon commented Jun 18 '19, 1:50 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your answer


Register or to post your answer.