Email Script Token resolution with multiple lookup objects.

Irwin_Horowitz
Level 2

Email Script Token resolution with multiple lookup objects.

We have a custom junction object in Salesforce, Clubs Volunteers, that links the Salesforce Contact object with custom object, Clubs.  We've created tokens for fields in the Clubs Volunteers object.  If there is only one Clubs Volunteer object for the contact record, the token resolves to the correct value.  If there is more than one club volunteer object for the contact record, the token does not resolve.

I can understand why this happens, and see a possible workaround by using a Marketo Custom Object for the club volunteer object.    Is there a why to filter the volunteer object in the Email Token Script without creating a Marketo custom object?  Adding a script filter doesn't help resolve the object if there's more than one.  When there's one record, the script below works.  More than one, it doesn't resolve.   

Thanks, Irwin

#if(${Club_Volunteer__cList.get(0).Club_Year__c} == "2016-17") 

     #set($Sponsor = "${Club_Volunteer__cList.get(0).Sponsor_Name__c}")   

     In IF     ${Club_Volunteer__cList.get(0).Sponsor_Name__c}

#end

$Sponsor

1 REPLY 1
Irwin_Horowitz
Level 2

Re: Email Script Token resolution with multiple lookup objects.

I can answer my own question.  In case anyone is interested.  Set up a velocity loop as below:

#foreach ($cv in $Club_Volunteer__cList)

   #if($cv.Club_Year__c == "2016-17")

     #set($Sponsor = "$cv.Sponsor_Name__c")

       In IF

       ${cv.Sponsor_Name__c}

    #end

#end

$Sponsor