“Null” First Name Solution

The issue is if the first name is “null”, the word, not just null as in the blank value.

This first checks to see if the first name is not null(blank), then it checks if it is “null” the word. If it is “null” the word then it returns the address first name, otherwise it returns the first_name. This example uses sample data from a Shopify Customer to NetSuite Customer import.

{{#if first_name}}{{#compare first_name “==” “null”}}{{addresses.[0].first_name}}{{else}}{{first_name}}{{/compare}}{{else}}{{addresses.[0].first_name}}{{/if}}

If you pass in the following data:

{
“last_order_name”: “#1001”,
“tags”: “”,
“verified_email”: true,
“updated_at”: “2015-03-28T13:29:45-04:00”,
“total_spent”: “41.94”,
“state”: “disabled”,
“orders_count”: 1,
“note”: null,
“multipass_identifier”: null,
“last_order_id”: 450789469,
“last_name”: “Smith”,
“id”: 207119551,
“first_name”: “Bob”,
“email”: “bob.smith@someeamil.com”,
“created_at”: “2015-03-28T13:29:45-04:00”,
“accepts_marketing”: false,
“currency”: “USA”,
“addresses”: [
     {
     “default”: true,
     “country_name”: “United States”,
     “country_code”: “US”,
     “province_code”: “CO”,
     “name”: “”,
     “zip”: “80202”,
     “province”: “Colorado”,
     “phone”: “303-867-5309”,
     “last_name”: null,
     “id”: 207119551,
     “first_name”: null,
     “country”: “United States”,
     “company”: null,
     “city”: “Denver”,
     “address2”: “”,
     “address1”: “123 Main St”
     }
   ]
}