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

@matthew_hughes 

if (gs.getProperty('propertyName').toString().split(',').indexOf(scheduleGR.table.toString()) > -1)

💡 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

SIVASANKARIS
Giga Guru

Hi @matthew_hughes ,

var tables = gs.getProperty('sn_apm_affected_certfification_element_tables', '');

if (tables.includes(scheduleGR.table)) {
    element_check.addQuery('id', current.id);
} else {
    element_check.addQuery('configuration_item', current.configuration_item);
}

element_check.addEncodedQuery('stateINPending,Failed');
element_check.query();

 

If this works, please mark it as helpful and accept my 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

@Ankur Bawiskar  Do I need to be cautious about white trim or should it be all ok?