How to add two or more sys_id in system property?

Suvronil Ghosh
Tera Contributor

I'm trying to add multiple sys_id in a single system property.

8 REPLIES 8

bandi
Tera Contributor
Hi Maniraj, I have sys ids for groups in script include help instead of hard-code i have to use system propertie. And implement in script include. Now my code please find the attachment please do the needful. Thank you

hello,

You can use something like this

var groupSysIds = gs.getProperty('property_name');
var gr= new GlideRecord('sys_user_grmember');
gr.addQuery('group', 'IN', groupSysIds);
gr.addQuery('user', gs.getUserID());
gr.query();

 

hi Saurav11, 

 

I need to add different groups sys id in system property and add them to a business rule. only if that group member is making the changes on the particular table and my below code should run . somewhere its not running properly 

    var devgroups = gs.getProperty('nhs.development.scrum.groups').split(',');
    var usergroups = gs.getUser().getMyGroups();
    var cancreatescrumtask = false;
    while (usergroups.next()) {
        if (devgroups.indexOf(usergroups.getValue('sys_id')) != -1) {
            cancreatescrumtask = true;
            break;
        }
    }

    if (cancreatescrumtask) {
//my code

Vaishnavi Lathk
Mega Sage
Mega Sage

In ServiceNow, if you want to add multiple sys_id values to a system property, you typically store them as a comma-separated string or use a specific format that your application logic can parse. Here's how you can do it:

  1. Navigate to System Properties:

    • Go to System Properties > All Properties in your ServiceNow instance.
  2. Create or Edit a Property:

    • Either create a new property by clicking New or edit an existing property by selecting it from the list.
  3. Set the Value:

    • In the value field, enter the sys_id values separated by commas. For example:
      sys_id1,sys_id2,sys_id3
  4. Save the Property:

    • Click on Submit or Update to save your changes.
  5. Accessing the Property in Code:

    • When you access this property in scripts, you can split the string into an array for processing. For e
      var sysIds = gs.getProperty('your.property.name').split(',');
  6. Handling Special Cases:

    • Ensure that any logic you implement can handle cases where the property might be empty or where the sys_ids might not be valid.