Creating URLs off $triggerObject | Community
Skip to main content
New Participant
September 11, 2018
Solved

Creating URLs off $triggerObject

  • September 11, 2018
  • 3 replies
  • 3629 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Mark_Price

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.

3 replies

SanfordWhiteman
New Participant
September 11, 2018

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.

Mark_PriceAccepted solution
New Participant
September 11, 2018

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
New Participant
September 11, 2018

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

WyattBaAuthor
New Participant
September 11, 2018

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.