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

Owned By: on change validation -> change "Owned By" value

 So I can't seem to change "Owned By" value after it's validated. Previously I was using a validator but I changed to Calculated Value to be able to change the value of the "Owned By".


In the validator, it ran fine, however the value was not changed of course, now that I have changed to calculated value it doesn't even run onto the validation.

What am I doing wrong?

edit: if the custom attribute "elvis" value is found or matches a value in the "Owned By" list, nothing happens but if it's not found then "Owned By" value should change to Unassigned.

// ----- CODE ------
dojo.provide("org.example.calculated.ValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
 dojo.declare("org.example.calculated.ValueProvider", null, {

getValue: function(attribute, workItem, configuration) {
var ownedByList = workItem._proxy._priorFetchEditablePropertiesEditProps.allValues[7].uiItems;
var elvisUserID = workItem._proxy.object.attributes.Elvis_UserID.content;
var elvisFound = false;
for (i = 0; i < ownedByList.length; i++) {
if(ownedByList[i].label.toLowerCase() == elvisUserID.toLowerCase()) {
elvisFound = true;
  }
  }
 
  if(elvisFound) {
  //Found Elvis User ID in Owned By List & continue
  alert('Elvis User ID found.');
  return; //nothing happens
  } else {
  //Elvis User ID not found in Owned By List then change value to unassigned.
alert('elvis user id not found in owned list');
return; //change "Owned By" value to Unassigned
  }
        }
    });
})();

thanks! take a look at the returns

0 votes



2 answers

Permanent link

I don't really know what you try to do, particularly with a flawed logic.

Your sample code doesn't change anything, as you put "return;" in both places.  Also, the way you get the attribute values looks quite dodgy. See the below article for proper ways to work with attributes.
https://jazz.net/wiki/bin/view/Main/AttributeCustomization

As for your original attempt, a validator only validates the value, and should return OK or errors depending on the situation. If you change the value, shouldn't the new value be "validated" again? The process just doesn't work like this.

I suggest you keep it simple. In the case that you want to set the value to Unassigned for whatever reason, I think it will be better to just return such (error) message by a validator to the UI.

0 votes


Permanent link

 Thanks for the reply! I managed to do it by returning the ID, I was trying other way but it works now, thanks though!

0 votes

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

Question asked: Mar 24 '17, 5:33 p.m.

Question was seen: 1,817 times

Last updated: Apr 03 '17, 10:29 a.m.

Confirmation Cancel Confirm