"Copy empty fields" Transform Map question

MG Casey
Mega Sage

I am importing data from a spreadsheet and am looking to overwrite target records' vendor number fields with empty data if the corresponding vendor number field in the spreadsheet is also empty.

I have checkmarked "Copy empty fields" as you would guess:

find_real_file.png

However, later, I have a business rule that runs based on if my vendor number field is empty. This business rule is not getting triggered since it now thinks the field value is "NULL" instead of just empty.

I use the following condition:
current.u_vendor_id_number.nil()

Why does a NULL field not count toward this condition?

4 REPLIES 4

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Mg,



What is the behaviour if you add that as part of condition filter in Business rule i.e vendor id number is empty


It's unfortunately not something I can add to the business rule's condition builder - it needs to be an IF statement with the script section of my business rule, checking whether or not the field is empty.



I guess I am mainly looking for a safer, broader way to tell if if a field is empty. I know of the following:


  • current.u_vendor_id_number.nil()
  • current.u_vendor_id_number == ''
  • current.u_vendor_id_number == 'NULL'


Is there a best practice on what covers the most scenarios for blank fields?


More confusion directly after transform...



Field: u_vendor_id_number


Value: (nothing, empty value retrieved from transform map)



"Before" Business Rule executed directly after transform:


ConditionResult
current.u_vendor_id_number.nil()FALSE
current.u_vendor_id_number == ''FALSE
current.u_vendor_id_number == nullFALSE
current.u_vendor_id_number == 'NULL'TRUE


Same "Before" Business Rule executed after normal update on record:  


ConditionResult
current.u_vendor_id_number.nil()TRUE
current.u_vendor_id_number == ''TRUE
current.u_vendor_id_number == nullFALSE
current.u_vendor_id_number == 'NULL'FALSE


Definitely seems contradictory even though the field value is all the same.


Hi Mg,



Thanks for the update. I would need to test this once at my end and then get back to you. Meanwhile here is the link to helpful blog. Please refer the same.


Defensive Coding: Check your Variables in Customizations


Also JSutill has few methods to check if the field value is blank or not.


JSUtil - ServiceNow Wiki