I'm trying to develop a velocity script where it checks if a field in a custom object (which is being synced from a Dynamics custom entity) is not empty. If this field is empty, I would like to print a message saying the details are not available at this time. The entity is being synced with Marketo using the standard process, and I can call information from this entity successfully in other scripts.
The data is structured as follows:
The contact/lead is linked a record on the 'contactQualification' object, this is a one-to-many relationship.
A qualification record has a lookup field to 'externalCourseList', this is a one-to-one relationship.
A courseList record has a field 'friendly name' which is what I would like to print.
Contacts can have multiple qualifications, but I'm happy to print only the most recent one (that is, only the record at index 0). If there are more than one, this is irrelevant.
My code is currently:
#if($contactqualificationList.isEmpty())
Your qualification details are not available at this time.
#elseif(!$contactqualificationList.get(0).qualificationid || $contactqualificationList.get(0).qualificationid.isEmpty())
Your qualification details are not available at this time.
#elseif($contactqualificationList.get(0).externalcourseList.isEmpty())
Your qualification details are not available at this time.
#else
You are studying $contactqualificationList.get(0).externalcourseList.get(0).name.
#end
My results from this are:
For records that have a qualification record - the script works successfully, and I can see the friendly name printing.
For all records that don't have this record filled in but do have a record on contactQualification (the field is null) - I get the following (not really helpful!) error:
Cannot get email content- <div>An error occurred when procesing the email Body! </div> <p>None.get near</p> <div><pre ></pre></div>
Records with no qualification applied to their record - the correct error message will display.
I do have another version of the code, but it is less reliable:
#if( $contactqualificationList.isEmpty() )
Your qualification details are not available at this time.
#elseif( $contactqualificationList.qualificationid.isEmpty() )
Your qualification details are not available at this time.
#else
You are studying $contactqualificationList.get(0).externalcourseList.get(0).name
#end
What is causing this error and how do I correctly reference if null fields in custom objects in Velocity? I am able to successfully use the isEmpty method in other scripts, however this example keeps failing! I have tried calling the data through a loop, but I will easily exceed the call limit.
... View more