It's all about the answers!

Ask a question

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

Martin Flores (111) | asked Mar 24 '17, 5:33 p.m.
edited Mar 24 '17, 5:35 p.m.

 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 ------

(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

2 answers

permanent link
Donald Nong (14.5k414) | answered Apr 03 '17, 12:20 a.m.

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.

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.

permanent link
Martin Flores (111) | answered Apr 03 '17, 10:29 a.m.

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

Your answer

Register or to post your answer.