Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Filter table based in array from system property

Not applicable

Hi ,

we have set many system properties which contains table names comma separated.

 

Example: hard.ci.pop 

Nisha30_0-1751290238016.png

1)need to call this property from Script Include

2) the result of this should be : 'Configuration Item' field should display records only from these tables.

 

How do I achieve this

 

Thanks

 

1 ACCEPTED SOLUTION

Hi @Community Alums ,

 

 

in the question you have share the property screenshot value contains ";" at the end

remove the ";" at the end of the property value in the system property

 

update the ref qual as below

 

javascript: "sys_class_nameIN" + new global.getincTables().getTableNames(current.getValue('category'));

 

 

 

update/keep the script include method as below

 

getTableNames: function(chkcategory) {
    chkcategory = chkcategory.toLowerCase();
    if (chkcategory == 'hardware')
        return gs.getProperty('inc.filter.hardware');
    else if (chkcategory == 'software')
        return gs.getProperty('inc.filter.software')
    else if (chkcategory == 'exchange')
        return gs.getProperty('inc.filter.exchange')
    else
        return ''
}

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

 

View solution in original post

23 REPLIES 23

Ankur Bawiskar
Tera Patron

@Community Alums 

I believe you have a reference field pointing to cmdb_ci parent table and want to see CIs only from these system property tables

If yes then use this in advanced ref qualifier of that reference field

javascript:"sys_class_nameIN" + gs.getProperty('hard.ci.pop');

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Community Alums 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Not applicable

Hi @Ankur Bawiskar 

that seems a good idea, but we have many system properties and not just single.
so based on category different system properties will be there and hence there should be different table.
Thanks

@Community Alums 

you can adjust it like this if category is a field on same form/table

something like this

If you have lot of categories to compare then create a script include function and call it from advanced ref qualifier and pass the category field value

javascript:var query; if(current.categoryField == 'value1') query = "sys_class_nameIN" + gs.getProperty('hard.ci.pop'); else if(current.categoryField == 'value2') query = "sys_class_nameIN" + gs.getProperty('property2'); query;

If my response helped please mark it correct and close the thread so that it benefits future readers.

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