Re: Using Email Script Tokens from Marketo Custom Objects in URLs

lauren_foy
Level 1

Using Email Script Tokens from Marketo Custom Objects in URLs

Hi there -- My team is new to Marketo and we're having a hard time getting a customized URL to populate from an email script token in one of our emails. 

 

We're using the following script for the token: 

#set($licenseSubmissionURL = ${accountDataSortedList[0].licenseSubmissionURL})
#set($docuSignLink = $licenseSubmissionURL.replaceAll("^https://powerforms.docusign.net/","") )
<a href="https://powerforms.docusign.net/${docuSignLink}">Click Here</a>

 

The issue we're running into is that the $docuSignLink tag is not properly loading upon send/preview so we're getting an error that the power form we're pointing to can't access $%7BdocuSignLink%7D. We've tried this using both ${docuSignLink} and $docuSignLink with the same results. 

 

We're all pretty new to velocity so I'm wondering if there are any helpful resources that may help us troubleshoot? I've dug through the community posts here, the developer guide, and the Apache toolkit which all tell me the above script should work. 

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: Using Email Script Tokens from Marketo Custom Objects in URLs

Please remember to use the syntax highlighter for readability (I edited your post).

 

There’s not much information here about your business goals and it’s always to explain what you’re trying to do with the data, rather than having us reverse-engineer your goals from non-working code!

 

Right now, you‘re referring to a List $accountDataSortedList. What is the shape of the objects in that list? Is that actually (I believe it is because of the name) the sorted version of a original List like $accountData_List, which you’re not showing?

 

You’re trying to strip the protocol + hostname from the beginning of the field, I assume because sometimes the value has a proto + host and sometimes it doesn’t and you want to normalize it? Please explain that. Also your regex should have "\.", not just ".".

 

lauren_foy
Level 1

Re: Using Email Script Tokens from Marketo Custom Objects in URLs

Thank you, Sanford! (and thanks for editing my post -- noted re. the syntax for next time)

 

To give you the context, my team is running a campaign to alert our partners when they need to submit their license renewal information. We have a one-to-many structure, in which some of our partners have multiple locations. Some of these locations may all come up for renewal on the same date and some may stagger throughout the year. Our flow is set up to trigger when the Custom Object field for the URL is updated and send a set of reminders to the partner for that specific location. For the partners with multiple locations, we were initially planning to send one email per location, meaning they'd potentially get two emails on the same day if they have two locations up for renewal that day.  Let me know if this still isn't clear!

 

We use a Marketo custom object to pull in the license submission URL into Marketo.  You're correct, I am using the script to strip the proto -- I was doing that so we could track the links vs using only the $link tag to pull in the full link. Since some accounts have multiple custom objects, we've used the $accountDataSortedList to sort by updated date the location (Account Data) objects in prior script tokens so we could pull in a few of the most up-to-date locations in a previous campaign. I ended up removing this step because it was not necessary for the goals of this campaign, to my current knowledge. 

 

I was able to partially solve the issue described in my earlier post by correcting some of my syntax errors so our links are now working correctly! However, it seems like because we're using the '<custom object> is updated' trigger, we're not able to control which custom object is shown in the email by using the Triggered Object velocity command. Based on the velocity documentation, we're not able to accommodate this part of the campaign. If you have any interesting workarounds we should consider for this new issue, I'm all ears. Otherwise, I can consider this post closed since I was able to solve the initial issue. 

 

Thanks again! 

SanfordWhiteman
Level 10 - Community Moderator

Re: Using Email Script Tokens from Marketo Custom Objects in URLs


We use a Marketo custom object to pull in the license submission URL into Marketo.  You're correct, I am using the script to strip the proto -- I was doing that so we could track the links vs using only the $link tag to pull in the full link.

OK, if you’re only trying to strip the protocol and double slash though, you don’t need to include/replace the hostname. That’s something that makes the code somewhat unclear.

 


we've used the $accountDataSortedList to sort by updated date the location (Account Data) objects in prior script tokens so we could pull in a few of the most up-to-date locations in a previous campaign. I ended up removing this step because it was not necessary for the goals of this campaign, to my current knowledge. 

That’s kind of surprising. You also mention you don’t know exactly which object in the list caused the trigger to fire, as $triggerObject isn’t working for the update. I would think you do want to sort the list by the last updated timestamp?

lauren_foy
Level 1

Re: Using Email Script Tokens from Marketo Custom Objects in URLs


OK, if you’re only trying to strip the protocol and double slash though, you don’t need to include/replace the hostname. That’s something that makes the code somewhat unclear.

Fantastic -- I will clean that line up a bit to remove the hostname. 



That’s kind of surprising. You also mention you don’t know exactly which object in the list caused the trigger to fire, as $triggerObject isn’t working for the update. I would think you do want to sort the list by the last updated timestamp?


Makes sense to add it back in for the partners that experience their renewals on different days so we can pull in the most recently updated. The issue I'm running into is that some partners will experience updates to multiple objects at the same time if more than one of their locations qualifies for the trigger at the same time/on the same day. My original thought was that this sorting was causing Marketo to only ever send the top/most recent object for each send. I could very well be missing something with this whole flow.