Alternative for dot walking in workflow script

Neeraja2
Tera Contributor

Hello Team,

 

I have one requirement in workflow script to set requested for request to variables from RITM. I used as "

current.variables.requested_for;". But they don't dot walking. Is there any alternative for this line of code to set requested for of request in script?
5 REPLIES 5

Maddysunil
Kilo Sage

@Neeraja2 

I think you can try something like below:

 

var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.variables.ritm)) { // Assuming 'ritm' is the variable holding the RITM sys_id
    var requestedFor = ritm.variables.requested_for; // Assuming 'requested_for' is the variable name
        current.requested_for = requestedFor;
} else {
    gs.info('Failed to get the associated RITM.');
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

Hi,
They don't want to use dot walking for

var requestedFor = ritm.variables.requested_for;

 Is there any other way to achieve this line in script?

Akif_Shah
Kilo Sage
Kilo Sage

You would need a run script activity in your Workflow 

var gr = new GlideRecord("sc_request");

gr.addEncodedQuery("sys_id="+current.request);
gr.query();
if(gr.next()){
   gr.requested_for = current.variables.requested_for;
   gr.update();
}

Hi,
They don't want to use dot walking for gr.requested_for = current.variables.requested_for; Is there any othe way to achieve this in script?