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

Nilesh Pol
Tera Guru

@Muhammad Salar there is a classic case of invisible characters or string format mismatch. verify the below code:

var prop = gs.getProperty('custom.excluded.services', '');
var formatted = prop.split(',').map(function(e) {
return e.trim();
}).join(',');
gs.info('[GetExcludedServices] Cleaned formatted value: ' + formatted);
return formatted;

i am using this script include in SLA start condition filter, this code is also not working unfortunately

mohdarbaz
Kilo Guru

Hi @Muhammad Salar ,

Sometimes, there might be hidden characters or spaces in the property value.

**

var prop = gs.getProperty('custom.excluded.services', '').trim();

**

If this response has helped you and your concern is solved, then click on a "helpful", & "Accept as Solution".

 

Regards,

Mohd Arbaz.

 

Yes, i have tried these things, no luck