Add sys id servicenow

servicenow14710
Tera Expert

Hello developers, i have an implementation where i need to add a sys id to an already existing array(this array values has been glided and result has been pushed.Any suggestions is appreciated. Thanks!

5 REPLIES 5

Hello @servicenow14710 

Thanks for clarifying the requirements.

Please try this script:

var grUser = new GlideRecord('sys_user'); //replace table name as per the requirement 
grUser.addEncodedQuery('nameLIKEJUHI^active=true'); //Replace query as needed
grUser.query();
//use "while" if multiple records and "if" for single record
if(grUser.next()){
	workflow.scratchpad.needed.push(grUser.sys_id); //push the new record sys_id
}
gs.info(workflow.scratchpad.needed);

Result:

JuhiPoddar_0-1731694638749.png

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar