Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Set owner script - graceful way to not execute?

I have successfully built a script that sets the Owned by attribute based on the value selected in an enumeration.  I then wanted to have it also check a boolean attribute and if that boolean is false, to NOT set the Owned by field, but to let the user set it.  I have this working, but not gracefully.

Below is a snippet of the code.  For the "else" condition I am simply returning an empty string instead of a UUID.  This has the intended effect - the Owned by attribute is not set automatically, but it of course results in a null pointer exception.  I was wondering if there was a better way to accomplish this so as not to throw an error?


(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

var SetECMOwner= dojo.declare("org.example.SetECMOwner", null, {

    getValue: function(attributeId, workItem, configuration) {

    // retrieve state of auto-assign attribute
    var autoAssign = workItem.getValue("delegateflag");
    // if auto-assign is turned on (by default), execute the body of the script
    if (autoAssign == true ) {
       DO SOME STUFF;
       return UUID
   }
   else {
       return "";
   }



0 votes



One answer

Permanent link
Hi,

I might be missing something but why not simply return the unassigned value for your OwnedBy field (usually "unassigned")? Would that have undesired side effects for your use case?

- Arne

0 votes

Comments

Thanks for the input.  Unassigned is not the desired end result, but rather whatever owner the user selects.  After thinking about it some more seems the answer is:

workItem.getValue(WorkItemAttributes.OWNER);

So basically setting owner to whatever owner is set to - the value the user specified.

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 369

Question asked: Jun 21 '12, 1:57 p.m.

Question was seen: 3,254 times

Last updated: Jun 26 '12, 4:15 p.m.

Confirmation Cancel Confirm