sys_id of the catalog variable

Abhishek64
Kilo Contributor

I  have to pass value from UI action page to my work flow where i am able to pass the incident value from work flow but not able to pass sys_id of the incident to my workflow. i am using below code to pass the incident number and sys id.

Working code 

ServiceNowIncidentId:current.variables.associatedincidentnumber.getDisplayValue(),

Not working code (not able to pass sys id to my workflow)

INSysid:current.variables.associatedincidentnumber.sys_id.getDisplayValue(),

1 ACCEPTED SOLUTION

Hi,

If your variable is of type string then you need to use GlideRecord query to get sys_id.

var incSys_id = '';
var incId = new GlideRecord('incident');
incId.addQuery('number',current.variables.associatedincidentnumber.toString());
incId.query();
if(incId.next()){
incSys_id = incId.getUniqueValue();
}
// put above code in your script and use incSys_id to pass sys_id
INSysid:incSys_id,

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

8 REPLIES 8

Hi,

What is the type of your variable 'associatedincidentnumber'?

Is it Reference or String?

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi,

If your variable is of type string then you need to use GlideRecord query to get sys_id.

var incSys_id = '';
var incId = new GlideRecord('incident');
incId.addQuery('number',current.variables.associatedincidentnumber.toString());
incId.query();
if(incId.next()){
incSys_id = incId.getUniqueValue();
}
// put above code in your script and use incSys_id to pass sys_id
INSysid:incSys_id,

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi @Abhishek 

May i know the field type ?

Can you share the snippets exactly what you want

 

Regards,

Naveen

 

Yes Filed type is Text but after changing it to Reference.below code is working fine

 

INSysid:current.variables.associatedincidentnumber.toString(),