SOLVED

Help with Custom Object Velocity Script

Go to solution
SimranNaidu_
Level 1

Help with Custom Object Velocity Script

We're attempting to make the body text dynamic using a velocity script that references a custom object on the SFDC Practice table. However, the script isn't yielding any output. The fields we're referencing are checkboxes (as shown in the screenshot). We suspect that the issue might be because we're using fields on the practice table (custom object) or because they are checkbox fields. Our theory is either correct, or there's an error in how we've written the velocity scripts (see the scripts labeled Velocity Script 1 and Velocity Script 2 below). We've tried using both 1/0 and True/False values in the script. 

Could you confirm if our theory is correct? If not, could you assist with correcting the velocity script?

 

Script 1 -

#if(${Practice__cList.get(0).meets_availability_threshold__c})
availability
#elseif(${Practice__cList.get(0).meets_insurance_threshold__c})
insurances
#elseif(${Practice__cList.get(0).meets_visit_reason_threshold__c})
visit reasons
#else
more budget
#end

 

Script 2 - 

#set($availabilityThreshold = ${Practice__cList.get(0).meets_availability_threshold__c})
#set($insuranceThreshold = ${Practice__cList.get(0).meets_insurance_threshold__c})
#set($visitReasonThreshold = ${Practice__cList.get(0).meets_visit_reason_threshold__c})
#set($bodyText = "")
#if($availabilityThreshold)
#set($bodyText = "availability")
#elseif($insuranceThreshold)
#set($bodyText = "insurances")
#elseif($visitReasonThreshold)
#set($bodyText = "visit reasons")
#end
${bodyText}

 

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Help with Custom Object Velocity Script

Please use the Syntax Highlighter (“Insert/edit code sample”) when posting code so it’s readable. I edited your post this time.

 

We suspect that the issue might be because we're using fields on the practice table (custom object) or because they are checkbox fields.

There’s no need to guess. Output the list $Practice__cList. That’ll tell you how the values are stored.

 

Also, you shouldn’t be just seeking the first (0-th) item in the list unless you have a specific and very good reason. You should consider the list to be unsorted.

View solution in original post

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Help with Custom Object Velocity Script

Please use the Syntax Highlighter (“Insert/edit code sample”) when posting code so it’s readable. I edited your post this time.

 

We suspect that the issue might be because we're using fields on the practice table (custom object) or because they are checkbox fields.

There’s no need to guess. Output the list $Practice__cList. That’ll tell you how the values are stored.

 

Also, you shouldn’t be just seeking the first (0-th) item in the list unless you have a specific and very good reason. You should consider the list to be unsorted.