Error in dateFormat handlebar expression when input is empty

Scenario:

The below given handlebar expression is used for date format conversion.

{{dateFormat “YYYY-MM-DD” custbody_field1 “DD-MM-YYYY”}}

An error is encountered when the field1 is empty in NetSuite.

Failed to generate field value from template: {{dateFormat “YYYY-MM-DD” custbody_field1 “DD-MM-YYYY”}}. Details: handlebars Helper {{dateFormat}} expects date argument when you have i/p date format.

Solution:

Modify the expression as below

{{#if custbody_field1 }}{{dateFormat “YYYY-MM-DD” custbody_field1 “DD-MM-YYYY”}}{{else}}{{/if}}

Also mark the “Discard if empty” option in the mapping.

Leave a comment

Your email address will not be published. Required fields are marked *