Issue: Dynamic Script condition in SLA filter value

Muhammad Salar
Giga Sage
        gs.info('[GetExcludedServices] Started');

        var prop = gs.getProperty('custom.excluded.services', '');
        gs.info('[GetExcludedServices] Property value: ' + prop);
      
        //var formatted = 'sys_id1,sys_id2';
        var formatted = prop.replace(/\s+/g, '');
        gs.info('[GetExcludedServices] Returning formatted value: ' + formatted);
        return formatted;

using this script include function in sla filter value (service.sys id is one of), when i am using manually var formatted = 'sys_id1,sys_id2'; it is working fine and when i am getting this from property, it's not working, any suggestions????
property value is same: sys_id1,sysid2
1 ACCEPTED SOLUTION

@Muhammad Salar 

gs.getProperty() has some issues when called from client callable script include

use GlideRecord to query sys_properties table with your name of property and then return the value

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

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

@Muhammad Salar 

you cannot directly call gs.getProperty()

Create a client callable script include and in that function use gs.getProperty() and return the sysIds

it worked fine as per this link

Can we call script include from SLA filter condition? 

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

@Ankur Bawiskar Yes, i am using this function in script include with glideajax and sandbox enabled.
Issue: when i am manually sending ids in same variable, script include and condition is working, it is not working when i am getting from the property, value is same in prperty

@Muhammad Salar 

gs.getProperty() has some issues when called from client callable script include

use GlideRecord to query sys_properties table with your name of property and then return the value

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

Thank you very much.

@Ankur Bawiskar I need to ask one more thing if you are available, I need to add NOT IN condition for reference field under sla condition for multiple values but there is not any operator available for that like 'is not one of' etc. I also tried dynamic filter, but that only works for true conditions like sys_id IN. 
Any suggestion?