How to set Contributor type field to Unassigned in Attribute Customization script?
We're trying to create a customized attribute script in Javascript where when a work item goes to a specific State, a custom field of type=Contributor will be automatically set to Unassigned.
I've done this before with UIDs for specific Team Members who should be the default value, but how would we represent Unassigned in the script rather than a specific user?
I've done this before with UIDs for specific Team Members who should be the default value, but how would we represent Unassigned in the script rather than a specific user?
Accepted answer
I would output the value of the literal Unassigned from the specific contributor attribute to a log or console or just another string field, then use that value to be returned from the script.
for example, when I set Owner attribute to Unassigned and run
var ownername = workItem.getValue(WorkItemAttributes.OWNER);
return ownername;
and capture the return on a string attribute, I get
_YNh4MOlsEdq4xpiOKg5hvA
as a value.
Now, from my script, I return this value and any Contributor attribute associated with this script gets set to Unassigned.
for example, when I set Owner attribute to Unassigned and run
var ownername = workItem.getValue(WorkItemAttributes.OWNER);
return ownername;
and capture the return on a string attribute, I get
_YNh4MOlsEdq4xpiOKg5hvA
as a value.
Now, from my script, I return this value and any Contributor attribute associated with this script gets set to Unassigned.
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Oct 16 '12, 12:51 a.m.Hi Michael. I was never able to set contributors in scripts. Can you provide an example of your script code that does it? Have you tried to set the contributor to null?
Michael Walker
Oct 19 '12, 3:06 a.m.Ralph,
I've been able to set the Owner field using scripts. I made the assumption that since our custom field was also a Contributor type that it would work the same.
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Oct 19 '12, 3:27 a.m.Michael,
I had tried this in 3.x, not sure which version. It never worked for me to pass the UUID in the script. But I have now verified that you can pass the UUID e.g. for a user and potentially other items (not tested that yet) and it will actually set the item.
This will go into the labs of our Process Enactment Workshop once we publish lab 5. Thanks so much for the answer which made me re-check!
Michael Walker
Oct 19 '12, 3:59 a.m.No problem Ralph. You've helped us a lot, so always happy to share what we have.
I actually stored the UID in a variable in the XML source and referenced the variable in my javascript. That way if the Owner changed we only needed to change the UID in the XML source and not modify the script.
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Oct 19 '12, 4:06 a.m.Interesting, can you share how you read the XML file?