Not able to push current.variables.requested_for value to "u_requested_for" on RITM form.

kumaraj
Kilo Sage

Hi All,

The approval for a catalog item is going to manager of the "u_requested_for" on the RITM form, so

I have requirement to push current.variables.requested_for value to "u_requested_for" on RITM form, so that as per variables.requested_for value should be pushed to "u_requested_for" on the RITM form as well and then as per workflow it will send the approval request as per "u_requeste.for" on the RITM.

My code:

condition on condition field: gs.getSession().isInteractive()

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

var VarReqFor = current.variables.hlr_requestedFor;
var RitmReqFor = current.opened_by;
if(current.variables.hlr_requestedFor){
//current.u_requested_for = current.variables.hlr_requestedFor;
current.setValue('u_requested_for',VarReqFor);
}

else{
//current.u_requested_for = current.opened_by;
current.setValue('u_requested_for',RitmReqFor);
}


if(current.cat_item.sys_id=='a99afbe44fa313c0605d451f0310c750'){
current.u_requested_for = current.variables.hlr_requestedFor;

var request1 = new GlideRecord('sc_request');
request1.addQuery('sys_id',current.request.sys_id);
request1.query();

if(request1.next()){
request1.requested_for=current.u_requested_for;
request1.update();
}

}
})(current, previous);

 

It is not working

4 REPLIES 4

Bogdan18
Tera Guru

Hi there,

 

If you have a workflow behind the catalog item then it is as simple as this:

 

Put a Run script activity right after the Begin activity and set the u_requested_for field like the below

var reqForVar= current.variables.request_for;
current.u_requested_for = reqForVar;

 

best regards,

Bogdan

Dubz
Mega Sage

Are u_requested for and variables.hlr_requestedFor both reference fields? Add a log to see what value and what type your VarReqFor variable is returning 

gs.log('value: ' + VarReqFor + ' type: ' + typeof VarReqFor);

kumaraj
Kilo Sage

Hi All,

 

Thanks fo your reply,

 

dvp
Mega Sage
Mega Sage

You can send approvals directly from the variables itself.

 

Use Advaced in Approval activity and use the following script

answer= [];

answer.push(current.variables.requested_for.toString())