update scratchpad variable through script

amaradiswamy
Kilo Sage

Hi All,

I have a if workflow activity which will return yes or no based on scratchpad variable. but, unfortunately for one request the scratchpad variable is assigned with wrong value and it is creating odd results, so is there anyway to change the value in scratchpad variable using scripts so that the workflow will follow correct path after the update.

Thanks and regards'

Swamy

1 ACCEPTED SOLUTION

i have used below script to update scratchpad variables and it worked.


var gr = new GlideRecord('sc_req_item');


gr.addQuery('sys_id','');


gr.query();


while(gr.next())


{


var wf = new Workflow().getRunningFlows(gr);


while(wf.next()) {        


    //new Workflow().broadcastEvent(wf.sys_id, 'pause');


wf.scratchpad.i = '23';


wf.update();


                  }




}


View solution in original post

7 REPLIES 7

i have used below script to update scratchpad variables and it worked.


var gr = new GlideRecord('sc_req_item');


gr.addQuery('sys_id','');


gr.query();


while(gr.next())


{


var wf = new Workflow().getRunningFlows(gr);


while(wf.next()) {        


    //new Workflow().broadcastEvent(wf.sys_id, 'pause');


wf.scratchpad.i = '23';


wf.update();


                  }




}


Nice work!


sumanteegala
Kilo Expert

yes..you can always change the workflow scratchpad variable. Check for Run script which will usually populates the scratchpad variables. Please change on   your variable.



workflow.scratchpad.variable name.