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

4078_TA
Tera Guru

Hi @matthew_hughes  ,

i can see the you have created the system properties but you  are not using in the business rule .

 

you ca get property values 

gs.getProperty('sn_apm_affected_certfification_element_tables')

 

this will retrieve those table names.

once you get this property value then split and use in you business rule 

 

 

If you found my solution helpful, please mark it as Helpful or Accepted Solution...!

thanks,

tejas

Email: adhalraotejas1018@gmail.com

LinkedIn: https://www.linkedin.com/in/tejas1018

Hi @4078_TA That is what I'm wanting to know. How do I apply the system property within my business rule so that I can get the table values to compare against?

kaustubhdub
Giga Guru

hey @matthew_hughes ,

you have created a system property but you are not actually using it here

Try the code below to get the system property in the br:

var affectedTables = gs.getProperty('sn_apm_affected_certfification_element_tables', '');
var tableList = affectedTables.split(',');

this above will help you actually get the value in the br itself.

 

Please mark helpful if you found my answer of any use.

 

Warm Regards

Kaustubh Dubey

Thanks @kaustubhdub  How do I included that in my if statement?