Using Location Data in Email Scripting | Community
Skip to main content
Eben_Saputra
Level 3
July 18, 2018
Solved

Using Location Data in Email Scripting

  • July 18, 2018
  • 1 reply
  • 5087 views

We have a JSON source of data with information on 150 locations. Based on a field ID in a person we would like to load the data for 1 of those locations into an email (Address etc).

We see two possible options but are seeing issues both routes:

  1. Import the data as a custom object with API into Marketo. Each location is a separate entry. The problem is how in my email do I load a specific entry based on a field ID in a Person?
  2. Import all the data as a token into Marketo. The problem I am stuck on here is how can I pull just the location I need (Do I have JSON Path or would it have to be nested array structure). and if the JSON structure were to change I would have to update every single email template (Instead of 1 piece of code for import).
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 SanfordWhiteman

You can't do this with a Custom Object -- there's no such thing as a shared CO (2nd-level CO) that's accessible from Velocity.  So [1] is just not an option. (Which is fine, [2] is a good approach.)

(Do I have JSON Path or would it have to be nested array structure). and if the JSON structure were to change I would have to update every single email template (Instead of 1 piece of code for import).

You don't have JSONPath, so you'd be iterating over a List or Map (of course any userland JSONPath implementation is actually doing the same thing).

I don't see why that would even be necessary, if the keys of a Map are your field IDs you can just seek right to them.

You also don't need to update any templates if your matching criteria change, just change the Velocity token that does the seeking.  One change in one place.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
July 18, 2018

You can't do this with a Custom Object -- there's no such thing as a shared CO (2nd-level CO) that's accessible from Velocity.  So [1] is just not an option. (Which is fine, [2] is a good approach.)

(Do I have JSON Path or would it have to be nested array structure). and if the JSON structure were to change I would have to update every single email template (Instead of 1 piece of code for import).

You don't have JSONPath, so you'd be iterating over a List or Map (of course any userland JSONPath implementation is actually doing the same thing).

I don't see why that would even be necessary, if the keys of a Map are your field IDs you can just seek right to them.

You also don't need to update any templates if your matching criteria change, just change the Velocity token that does the seeking.  One change in one place.

July 19, 2018

I am trying to import the data with the API, It looks like i can't import a Script token with the API, Can I import a text token with API and then use that in my email script as the "data source"?

SanfordWhiteman
Level 10
July 19, 2018

You certainly can modify a script token via API. I do it all the time. What endpoint were you trying and what payload?