How to get the previous value of the field in Business rule?

Dinesh Kumar5
Kilo Contributor

We want to update the value of the current field  depends on the value of the previous field .

 

 

 

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

var v = new GlideRecord('u_meeting_booking_details');
var prev1= previous.getvalue("u_string_1");            // unable to get the value using this syntax
gs.addInfoMessage(prev1);
var prev2= previous.getvalue("u_room_status");     // unable to get the value using this syntax
gs.addInfoMessage(prev2);
v.query();


while(v.next())
{

if(current.u_add_room == "volga"){

if(prev1 == "yes")
{
current.setValue("u_string_1","no");
current.setValue("u_room_status","yes");
}

else
{
current.setValue("u_string_1","yes");
current.setValue("u_room_status","no");

}

}
current.update();

}
})(current, previous);

21 REPLIES 21

asifnoor
Kilo Patron

Hello Dinesh,

The previous object will not be available if you have selected async. Kindly check.

Mark the comment as a correct answer and helpful if it helps.

Hello Dinesh,

When you say previous, you meant the previous value on the record before updation or anything else? Your requirement is not fully clear. Would be great if you can elaborate your requirement of what you want to achieve with screenshots and it would be easier to assist you.

If you are on skype or webex, let us know and we can connect and look into it.