It's all about the answers!

Ask a question

Can I get the previous value of an attribute during a validator?


Susan Hanson (1.6k2201194) | asked Jul 27 '13, 8:23 p.m.
Within a JavaScript-based validator, I can get the value of an attribute to validate.  Can I get the PREVIOUS value of the attribute?  We have attribute validation set in the operational behaviors, which (i believe) means that the all validators will be run on a save.

In my scenario, I want to determine whether on THIS save, the user is changing the value of an attribute from something else to the current.  We restrict access to modify a certain attribute to people of a certain role.  When people try to change the FiledAgainst (category) attribute, RTC does some interesting things because it crosses a process boundary.  If that attribute is set to something other than its' default, the cross of the process boundary resets it to the default and then changes it to the current value and therefore, anyone without permission to change that attribute get an error, even though they didn't actually CHANGE the value of that attribute (they ONLY changed the FiledAgainst). I've submitted a bug/enhancement request for this but I don't believe it is available yet.

So I thought I could remove the permissions check and do the check within a validator on the restricted field, checking the previous value.  If the previous and current values match, then this Save action is not attempting to change that field, so always valid.  If the previous and current values are different, then I can check the current user by UUID (we only have 3 people who can set this value) and give an error if you are not one of the 3 known people who can change it.

But I need to be able to know what the current AND previous value of the attribute are.

Susan

One answer



permanent link
Ralph Schoon (63.1k33645) | answered Jul 28 '13, 5:39 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
 In JavaScript: no you can't. In Java, maybe. 
What you try is doable with an advisor and not with a validator.

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.