SOLVED

Creating URLs off $triggerObject

Go to solution
Wyatt_Bales4
Level 4

Creating URLs off $triggerObject

Yet another Velocity question for Sanford Whiteman​ or someone with similar experience.

We create URL's based on an ID of the most recently updated custom object. The issue is, even though the ID field is populated 100% of the time and there is no duplicate Contact, the variable doesn't load consistently.

##IF A NET-NEW ONBOARDING RECORD IS CREATED, PULL ITS ACCOUNT ID##

#if ($context.contains("TriggerObject"))

#set ($focusedObject = $TriggerObject)

##IF AN EXISTING ONBOARDING RECORD IS UPDATED, PULL ITS ACCOUNT ID##

#elseif ($context.contains("OnboardingRelationship_cList"))

#set ($focusedObject = $sorter.sort($OnboardingRelationship_cList,"updatedAt:desc")[0])

#end

##IF PHOTOGRAPHY ISN'T SCHEDULED, DISPLAY TEXT BLOCK, ELSE NOTHING##

#if ($focusedObject.Photography_Scheduled__c == 0)

<b>Photography</b><br>

Please click <a href ="https://website.com/new/photos?flow=uk-s&sfid=$focusedObject.accountID">here</a> to book your photography. We will upload your photos once they’re ready. In the meantime you can go ahead and start accepting orders!<br>##

#else

#end

The website url actually shows the variable name instead of the ID. Yes, I've made sure the box is checked and I'm not using send sample functionality.

Appreciate any thoughts or ideas.

1 ACCEPTED SOLUTION

Accepted Solutions
Mark_Price
Level 7

Re: Creating URLs off $triggerObject

I would try formal notation on the variable and see what it does:

##IF PHOTOGRAPHY ISN'T SCHEDULED, DISPLAY TEXT BLOCK, ELSE NOTHING## 

#if ($focusedObject.Photography_Scheduled__c == 0) 

<b>Photography</b><br> 

Please click <a href ="https://website.com/new/photos?flow=uk-s&sfid=${focusedObject.accountID}">here</a> to book your photography. We will upload your photos once they’re ready. In the meantime you can go ahead and start accepting orders!<br>## 

#else 

#end

^ I've seen an issue where if you are not using formal notation, the link can break when it's wrapped for link tracking and it outputs the variable name.  Previews will probably show it as working, but a live message may not be working.

View solution in original post

5 REPLIES 5
Wyatt_Bales4
Level 4

Re: Creating URLs off $triggerObject

To clarify, the url sometimes loads correctly. When I run a separate test batch campaign, the token works. When the trigger fires multiple times within an hour, sometimes it's populated with the ID, other times is $focusedObject.accountID.

Mark_Price
Level 7

Re: Creating URLs off $triggerObject

I would try formal notation on the variable and see what it does:

##IF PHOTOGRAPHY ISN'T SCHEDULED, DISPLAY TEXT BLOCK, ELSE NOTHING## 

#if ($focusedObject.Photography_Scheduled__c == 0) 

<b>Photography</b><br> 

Please click <a href ="https://website.com/new/photos?flow=uk-s&sfid=${focusedObject.accountID}">here</a> to book your photography. We will upload your photos once they’re ready. In the meantime you can go ahead and start accepting orders!<br>## 

#else 

#end

^ I've seen an issue where if you are not using formal notation, the link can break when it's wrapped for link tracking and it outputs the variable name.  Previews will probably show it as working, but a live message may not be working.

SanfordWhiteman
Level 10 - Community Moderator

Re: Creating URLs off $triggerObject

Agreed, in this context I would use formal notation. Inside double quotes (and nowhere else!) is the place for it.

Wyatt_Bales4
Level 4

Re: Creating URLs off $triggerObject

I had the same hunch so I broke it out like so to test:

Focused Account: $focusedObject.accountID<br>

{Focused Account}: ${focusedObject.accountID}<br>

Focused Account URL: www.whatisthis.com/$focusedObject.accountID/stuff<br>

{Focused Account URL}: www.whatisthis.com/${focusedObject.accountID}/stuff<br>

{AccountCaseSafeID}: ${lead.AccountCaseSafeID__c}<br>

AccountCaseSafeID: $lead.AccountCaseSafeID__c

This morning all ID's were generated--not just the ${var} ones which is very peculiar. I honestly can't find any commonality on why Marketo would sometimes choose to load or not. I've tried Added to vs Updated triggers as well as Marketo custom object vs normal lead fields. That being said, the most consistently populated URL's are the ones with ${var} brackets so appreciate you reiterating that.

Appreciate both your help.

SanfordWhiteman
Level 10 - Community Moderator

Re: Creating URLs off $triggerObject

The next/first step for debugging is to output the $focusedObject by itself. Otherwise we can't see the contrast when the object exists, but the object property doesn't seem to output.