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

Joe Wong
Tera Guru

To clarify, do you want the sysID to be the key of the array? 

 

Or do you want to push the sysID into the array as well?  If so, what is the other of the array?  How will it look like?

Hello @Joe Wong , thanks for quick response

array is like 

    workflow.scratchpad.needed.push(gr1.getValue('sys_id'));
to this array i need to add another sys id(which is static value)Let me know if it is precise.
Thanks!
 

Juhi Poddar
Kilo Patron

Hello @servicenow14710 

The best way to add sys_id is to add them in system properties.

Steps to meet the requirement:

  • Create a new record in "sys_properties" table JuhiPoddar_0-1731675599858.png

     

  • Use this property to get the sys_id. Here is the updated script:

 

var propertyValue = gs.getProperty('community Help'); // Replace 'community Help' with your actual system property name.
workflow.scratchpad.needed.push(propertyValue);

 

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

Hi @Juhi Poddar : i need to add the new sys_id to already existing array which is like workflow.scratchpad.needed.push(gr1.getValue('sys_id')); 

 eg: workflow.scratchpad.needed = [a,b,c]

new static sys_id ='z';

it should be workflow.scratchpad.needed = ['a','b','c','z']Note:'a','b','c','d' - are all sys_id's. Thanks!