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

getting the previous value of the attribute using javascript in RTC

 I'm trying to write a validation customization in RTC, which would compare the previous value and new value of the attribute.


The validation would fail if either previous or new value contains certain 'sub-string'.

Guess, all the attribute customization functions return only new / current value of the attribute.

I have tried using the additional attribute with calculated value customization to store previous value, but it still does not work as expected in some of the cases for validation to be successful.

0 votes


Accepted answer

Permanent link

It is not possible to access the previous value of an attribute in JavaScript attribute configuration. What you are trying should be implemented as a work item save advisor. See https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ as an example for an advisor. In the Java API you can access the old and the new state.


 
"I have tried using the additional attribute with calculated value customization to store previous value, but it still does not work as expected in some of the cases for validation to be successful."

This is an ugly hack and the statement does not provide enough information to help, in case you expected help. 

Vivek Pandey selected this answer as the correct answer

0 votes

Comments

 Thank you Ralph !

the hack is something like this :

1. For Attribute A, I have created attribute B, 
2. so whenever, Value of A does not contain string "Freeze" , value of A gets copied to Attribute B.
3. When Value of A contains string ' freeze' , value of attribute B is not changed ( giving me previous value).
4. So, Validation fails if , either Attribute A or B value contains string 'Freeze' , Validation on save of workitem fails.
5. so, this way, I'm restricting addition or removal from freeze status of the attribute.

Above works but big problem with this solution is, even if some other attribute C is changed or status is changed, validation rule is run and it throws error.

So, I was looking for validation only when attribute A changes  ( I know that may not be possible), so, was interested to check, if there is any other way to capture the previous value of the attribute A and fail validation based on it.


I don't know if you can get it working with the hack you use. I would discourage trying. See https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ as an example for an advisor. In the Java API you can access the old and the new state. The download from https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ should have the code.

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 16 '17, 3:59 a.m.

Question was seen: 2,487 times

Last updated: Mar 16 '17, 8:30 a.m.

Confirmation Cancel Confirm