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

Anil Lande
Kilo Patron

Hi,

To pass sys_id you don't need to use getDisplayValue().

You can use like below:

INSysid:current.variables.associatedincidentnumber.sys_id.toString();

 

 

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 Anil,

 

Thanks for your response but below code is not passing the sys id value

 

INSysid:current.variables.associatedincidentnumber.sys_id.toString();

naveen14
Kilo Guru

Hi @Abhishek ,

Is you variable is reference ,use below code;

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

Regards,

Naveen

Thanks naveeb,

 

it is passing the Incident number but i need to pass the sys_id of the incident.