Attribute customization condition for precondition
![](http://jazz.net/_images/myphoto/31bdffa9d44e9a2384252a458c26da5b.jpg)
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
![](http://jazz.net/_images/myphoto/31bdffa9d44e9a2384252a458c26da5b.jpg)
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.
Comments
![](http://jazz.net/_images/myphoto/31bdffa9d44e9a2384252a458c26da5b.jpg)
Thank you davyd!
![](http://jazz.net/_images/myphoto/31bdffa9d44e9a2384252a458c26da5b.jpg)
Are there any resources you would recommend to help with learning this type of scripting aside from this part of the wiki?
![](http://jazz.net/_images/myphoto/31bdffa9d44e9a2384252a458c26da5b.jpg)
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?
![](http://jazz.net/_images/myphoto/31bdffa9d44e9a2384252a458c26da5b.jpg)
Nevermind, there was attribute confusion based on IDs. Thank you again!