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

RaghavSh
Kilo Patron

you can use source.u_alias==''


Raghav
MVP 2023

Ankur Bawiskar
Tera Patron
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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader