Calculated Value to set an enum attribute to a certain value based on status change
![]() Hi Everyone,
I am trying to set a custom enum attribute to a certain value based on status change in a work-item using the below script. but code is not going in to the function, request someone to provide me suggestions:
Code:
dojo.provide("com.example.Project_SetAttrIsanOpportunity");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); (function() { dojo.declare("com.example.Project_SetAttrIsanOpportunity", null, { getValue: function(attribute, workItem, configuration) { var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes; var type = workItem.getLabel(WorkItemAttributes.TYPE); var state = workItem.getLabel(WorkItemAttributes.STATE); //var Yattr = workItem.getAttributeData('y_n.literal.l1'); //var Nattr = workItem.getAttributeData('y_n.literal.l2'); if (type != null && type == 'Project') { var IsanOpportunity = workItem.getValue('com.stellantis.team.project.IsanOpportunity2'); if (state != "Proposed" || state != "Prioritize") return 'y_n.literal.l2'; if (state == "Proposed" || state == "Prioritize") return 'y_n.literal.l1'; } } }); })(); |
One answer
![]()
Ralph Schoon (61.5k●3●36●43)
| answered Jan 19, 3:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER My 2 cents
Comments Hi Ralph,
Thanks for the answer, Can you please help in these 2 points:
1. I initially tested the same script in condition, but the result is same.
2. I am returning the value under the if condition, Can you please tell me what part of the code is wrong in returning the enum value?
Thanks in advance
Hi Ralph,
Thanks for the suggestions, I will look into those and incorporate the changes. May I know whether it is possible to change the enum value based on workflow state ?
If yes, can you please help me with few references. I am new to this domain, appreciate your help.
Thanks in advance.
![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I thought I have made it as clear as possible already. I do not think that you can use attribute customization to change the enum value based on workflow state (change), because you can not detect the state change, at least not easily. Short answer: NO. It would be nice if you could automate attribute customization on state changes, feel free to create an enhancement request.
|