Populate original value of Assessment Instance Question?

SandyL83
Tera Guru

Hello,

 I have updated our Assessments to that the asmt_assessment_instance_question value can be updated. 

I am looking to store the original value that was present when the assessment was submitted. 

I thought I had it working yesterday, then we cloned down our instance and my business rule was lost. Now I redid it and it's not working. here is the business rule I am trying to use..

SandyL83_0-1680789984677.png

 

Here is the code:

(function executeRule(current, previous /*null when async*/) {

 

    current.original_value = previous.value; 

 

})(current, previous);

 

What am I missing?

 

there is a column titled "original_value", and the field the user is able to update is "value"...

Any ideas?


Thanks,

1 ACCEPTED SOLUTION

Bert_c1
Kilo Patron

Hi,

 

It appears that your business rule runs "After" and there is no "current.update();" (which is to be avoided in an After BR). Set your BR to run "Before".

View solution in original post

10 REPLIES 10

Bert_c1
Kilo Patron

Hi,

 

It appears that your business rule runs "After" and there is no "current.update();" (which is to be avoided in an After BR). Set your BR to run "Before".

Hi, thanks for your response. 

I updated it to "Before", and then here is my updated script: it still doesn't seem to be working. 

(function executeRule(current, previous /*null when async*/) {

    current.original_value = current.value; 
    current.update();
})(current, previous);

SandyL83
Tera Guru

got it to work - thanks for the help. it actually works on After. 

THank you!

Actually @Bert_c1  - so here is what happened. When I have it set to "After" and Insert and Update are selected, this code works.. but then I realized the Original Value was being updated whenever Value was updated. I want the Original Value not to change when Value is changed. So at this point, I've tried setting it to "Before" and "Insert" and "After and "Insert" and it's not working. THe only time I can even get the original value to populate is when both Insert and Update are selected. Do you have any idea why this would be happening? THanks!

(function executeRule(current, previous /*null when async*/) {

 

    current.original_value = current.value; 
    current.update();
})(current, previous);