Business Rule is updating previous value on task table

Priya Singh 2 2
Tera Contributor

Hi Team my requirement is that I have to create one catalog item and on that catalog item I don't need to show all variables on portal but I am showing all variables on request and some of the variables on task, now requestor wants to update task variable value on task description.

 

I have written before update BR - 

 

(function executeRule(current, previous /*null when async*/ ) {
 // Add your code here
var keys = new Array();
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.request_item);
set.load();
var vs = set.getFlatQuestions();
var description = '';
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getLabel() != '' && vs.get(i).getDisplayValue() != '' && vs.get(i).getDisplayValue() != 'false') {
description = description + vs.get(i).getLabel() + " : " + vs.get(i).getDisplayValue() + "\n";
        }
    }
    current.description = description;
 
Issue is that it's updating previous value not the value which I change currently.
For ex - I changed Priority to high on task variable it will not do anything
But next time I changed it to critical then on task description it will be showing as high 
 
Please advise, thanks in advance



})(current, previous);
5 REPLIES 5

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @Priya Singh 2 2 ,

 

Instead of using the before Business rule, can you try the after business rule. As the variables are not the fields on form maybe that's the reason you are not getting the new variable value before updating.

 

Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.


Regards,

Siddhesh

I tried with after update but it's not working.

Mark Manders
Mega Patron

I think your issue is in the before part of your business rule. Can you make it after or async?

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

I tried with after BR but it's not working.