Zoho Writer and Zoho CRM Integration

Zoho Writer and Zoho CRM Integration

Novice user here.  With the help of Zoho team we created a button in our custom module that with the click of the button, it will create & email pdf of a prep sheet document from the various fields/values in our CRM.   At the suggestion of Zoho, I've made the document in Zoho Writer where it's mapped a ton of fields from Zoho CRM.  

I've gotten the Deluge code to work, however if a variable''s value is blank in CRM , function will either throw an error or still create/email the the Mail Merge doc template with all the field mapping exposed (won't merge any of the 50+ fields).  Can anyone help out this novice user? 

What I want to happen is for the document to still be created/emailed and merge whatever values are available (there are a bunch of variables we noted in the code).  The other fields that do not have value, leave empty.   I don't know what to use in Deluge to make this requirement work.

Thanks all!