Filter table based in array from system property

Nisha30
Kilo Sage

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 @Nisha30 ,

 

 

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

@Nisha30 

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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

HI @Ankur Bawiskar 

yeah have Script include but not working below is the SI function

 

 

Nisha30_1-1751294570631.png

and the dictionary

Nisha30_2-1751294601750.png

 

 

   getTableNames: function(chkcategory)
        {
            var arr = [];
            if(chkcategory == 'Hardware')
            {
                var hardTable = gs.getProperty('inc.filter.hardware');
                arr.push('sys_id');
                return arr;
            }
            if(chkcategory == 'Software')
            {
                var softTable = gs.getProperty('inc.filter.software');
                arr.push('sys_id');
                return arr;
            }
            if(chkcategory == 'Exchange')
            {
                var hardTable = gs.getProperty('inc.filter.exchange');
                arr.push('sys_id');
                return arr;
            }
        },

 

 

@Nisha30 

try this

I assume you are comparing correct category value

advanced ref qualifier as this

javascript: "sys_class_nameIN" + new incUtils().getTableNames(current.category);
getTableNames: function(chkcategory) {
    var arr = [];
    var propertyValue = '';
    if (chkcategory == 'Hardware') {
        propertyValue = gs.getProperty('inc.filter.hardware');
    }
    if (chkcategory == 'Software') {
        propertyValue = gs.getProperty('inc.filter.software');
    }
    if (chkcategory == 'Exchange') {
        propertyValuehardTable = gs.getProperty('inc.filter.exchange');
    }
    return propertyValue;
},

I believe I already answered your question and you can enhance it based on your requirement and your development skills.

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

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

Hi @Ankur Bawiskar 

tried the above code . I put logs and it gives the value in logs i can see,

however the Configuration Item field is not populated with records related to that table. its empty as in snap shot

Nisha30_2-1751366633072.png

 

Nisha30_3-1751366745288.png

 

@Nisha30 

I believe issue is with the category value not getting fetched as it's a new record.

Also did you create/update the OOTB dictionary override for CI field as it's at task level

AnkurBawiskar_0-1751367269377.png

 

AnkurBawiskar_1-1751367306401.png

 

print category value in logs

getTableNames: function(chkcategory) {
gs.info(chkcategory); // if this doesn't give you the value then it won't work
    var arr = [];
    var propertyValue = '';
    if (chkcategory == 'Hardware') {
        propertyValue = gs.getProperty('inc.filter.hardware');
    }
    if (chkcategory == 'Software') {
        propertyValue = gs.getProperty('inc.filter.software');
    }
    if (chkcategory == 'Exchange') {
        propertyValuehardTable = gs.getProperty('inc.filter.exchange');
    }
    return propertyValue;
},

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

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