Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Transform map script issue -- scoped application

_navin9898
Tera Expert

Hi Team,

I have requirement where I need to check if a source field is empty in an excel file while import and trigger a notification based on that.

For example: I am receiving Task number(s) in excel which needs to be processed further. Now there are some scenarios where this file could be empty as you can see in attached; in that case I need to trigger a notification to relevant people.

 

I am seeing an issue where I am not able to read 'Task number' field using onbefore transform map script. If value of Task number is present then onbefore script is working, however if field is empty and we try to read the value by using below and try to print the same, it is not retuning anything.

 

var task_number = source.u_task_number;

gs.info(task_number);

 

My assumption is that if file is empty, above code should return empty value/string.

Could someone please redirect me to the right direction and let me know what I am doing wrong?

 

Best Regards,

Naveen

 

 

 

 

 

 

 

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@_navin9898 

you can try to check null value as well

var task_number = source.u_task_number;

if(task_number == '' || task_number == null){
	// your logic here
}

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 

 

Thank you for your prompt response!

Let me try that, will update you soon.

 

Best Regards,

Naveen 

Hi @Ankur Bawiskar 

I tried above solution but unfortunately it didn't work.

 

Best Regards,

Naveen

@_navin9898 

without you sharing complete script we won't be able to help.

also share screenshots.

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