It's all about the answers!

Ask a question

How to set Contributor type field to Unassigned in Attribute Customization script?


Michael Walker (99215201157) | asked Oct 15 '12, 5:18 p.m.
edited Apr 02 '13, 4:03 a.m. by Ralph Schoon (63.5k33646)
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?



Comments
Ralph Schoon commented Oct 16 '12, 12:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 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 commented 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 commented Oct 19 '12, 3:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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 commented 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 commented Oct 19 '12, 4:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Interesting, can you share how you read the XML file?

Accepted answer


permanent link
Dinesh Kumar B (4.1k413) | answered Oct 16 '12, 3:03 p.m.
JAZZ DEVELOPER
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.
Michael Walker selected this answer as the correct answer

Comments
Michael Walker commented Oct 19 '12, 3:04 a.m.

Thanks Dinesh...I was wondering if Unassigned had a UID value.

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.