Query tables mentioned within a System Property against an if statement

matthew_hughes
Kilo Sage

I've created a new system property called 'sn_apm_affected_certfification_element_tables' that mentions the below tables:

matthew_hughes_0-1768293329125.png

 

I've got a business rule that uses the below if statement:

if (scheduleGR.table == 'cmdb_software_product_model')
            element_check.addQuery('id', current.id);
        else
            element_check.addQuery('configuration_item', current.configuration_item);
        element_check.addEncodedQuery('stateINPending,Failed');
        element_check.query();
 
Does anyone know how I can replace or update 'if (scheduleGR.table == 'cmdb_software_product_model')' to reference my system property?

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

@matthew_hughes 

try this

if (gs.getProperty('propertyName').toString().split(',').indexOf(scheduleGR.table.toString()) > -1)
    element_check.addQuery('id', current.id);
else
    element_check.addQuery('configuration_item', current.configuration_item);
element_check.addEncodedQuery('stateINPending,Failed');
element_check.query();

If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Anand Kumar P
Tera Patron

Hi @matthew_hughes ,

Use below script to call the system property.

if(gs.getProperty('sn_apm_affected_certfification_element_tables').split(',').indexOf(scheduleGR.table) > -1) {
// your br script 
}

 

If my response helped, please mark it as the accepted solution and give a thumbs up👍.
Thanks,
Anand