Need to get the old value of a variable in RITM

san1989
Giga Guru

Hi All,

I have a requirement, I need to check whether the variable value has changed in the RITM process and send the notification to the requested_for as the variable value you entered is updated.

Can you guys please help me on this.

Thanks

1 ACCEPTED SOLUTION

san1989
Giga Guru

Hi All,

Thanks for your reply,

I have created on submit client script and script include for checking the old and new values of the variable on the (RITM) and sending notification if it is changed. The below one is working.

Client script, on submit():

var el_id = g_sc_form.getControl("u_impact_assessment").id;

//u_impact_assessment it is the variable name


var orig_val = gel("sys_original."+ el_id).value;
var new_val = g_form.getValue("u_impact_assessment");

if(orig_val != new_val){
var ga = new GlideAjax('ModelCategoryDet');
ga.addParam('sysparm_name','sendNotification');
ga.addParam('sysparm_sys_id',g_form.getUniqueValue());
ga.getXML();
}

Script include:

sendNotification: function() {
var Sys_id = this.getParameter('sysparm_sys_id');
var gr = new GlideRecord("sc_req_item");
gr.get(Sys_id);
gs.eventQueue('XXXX',gr,'','');

}

View solution in original post

6 REPLIES 6

vinothkumar
Tera Guru

You can create one more hidden variable and the  requested for value is changed, you can copy that old value to the hidden variable  using onChange client script and make your logic to work

Kalaiarasan Pus
Giga Sage

current.variables.variablename.changes() should work in the business rule as fas as I can remember. Have you tried using it?

I do not think variable values are audited. So I do not think you can access its history but you can track the change in real time using the above function.

Harsh Vardhan
Giga Patron

you can play with sys_history_line table where if you find "old" column is an empty then it means record has not updated/modified , if it contains some value it means variable value has changed.

try and let me know if you need any further help here.

in history line table variable stored in field column as "VARIABLE:<variable_name>

san1989
Giga Guru

Hi All,

Thanks for your reply,

I have created on submit client script and script include for checking the old and new values of the variable on the (RITM) and sending notification if it is changed. The below one is working.

Client script, on submit():

var el_id = g_sc_form.getControl("u_impact_assessment").id;

//u_impact_assessment it is the variable name


var orig_val = gel("sys_original."+ el_id).value;
var new_val = g_form.getValue("u_impact_assessment");

if(orig_val != new_val){
var ga = new GlideAjax('ModelCategoryDet');
ga.addParam('sysparm_name','sendNotification');
ga.addParam('sysparm_sys_id',g_form.getUniqueValue());
ga.getXML();
}

Script include:

sendNotification: function() {
var Sys_id = this.getParameter('sysparm_sys_id');
var gr = new GlideRecord("sc_req_item");
gr.get(Sys_id);
gs.eventQueue('XXXX',gr,'','');

}