Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

nil() function is not working in scoped application in onbefore transform script

Indraja Pandiri
Tera Contributor

HI Team,

I want to check the condition in onbefore script of a scoped app with conditions, if the source field does not contain "vplex" field or the source field is empty we have to ignore the record. the code is working for first condition but it is not working for nil() condition.

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here
    if((source.u_alias.toLowerCase().indexOf('vplex')== -1) || (source.u_alias.nil()) ) 
        ignore = true;

})(source, map, log, target);

 

Kindly let me know, what is the solution.
    

 

 

2 REPLIES 2

Raghav Sharma24
Giga Patron

you can use source.u_alias==''

Ankur Bawiskar
Tera Patron

Hi,

please use OOB ServiceNow JSUtil class. It works in global + scope app

JSUtil - Global

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

	// Add your code here
	if(source.u_alias.toLowerCase().indexOf('vplex') == -1 || global.JSUtil(source.u_alias)) 
		ignore = true;

})(source, map, log, target);

Regards
Ankur

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