SOLVED

Re: Custom object data via token

Go to solution
Anonymous
Not applicable

Custom object data via token

Can I access custom object data via a token? Could not find any info in the docs and got an error in my smart campaigns.

Screenshot 2017-02-21 13.14.05.png

The custom object is tied to the lead via id, how can I reference that lead's instance of the object?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Custom object data via token

You can't access COs as tokens in a simple Flow context, only in a Velocity context.

View solution in original post

10 REPLIES 10
SanfordWhiteman
Level 10 - Community Moderator

Re: Custom object data via token

You can't access COs as tokens in a simple Flow context, only in a Velocity context.

Anonymous
Not applicable

Re: Custom object data via token

Well that's a bummer.

Thanks for the quick response.

SanfordWhiteman
Level 10 - Community Moderator

Re: Custom object data via token

What are you trying to do exactly?

Anonymous
Not applicable

Re: Custom object data via token

Our event integration writes to the custom object directly, looking to set up smart campaign to write some of the values to fields on the lead too so it can sync to our CRM. I'm waiting to hear back if your integration allows us to write to the lead and custom object record at the same time, just testing fall back plans.

SanfordWhiteman
Level 10 - Community Moderator

Re: Custom object data via token

A two-phase commit (to CO and to lead field) might be a workaround.

But presumably you're using COs for the 1:N lead:object relationship, right? A single lead field can actually perform much the same function, if you store the objects as an append-only JSON array (every new object becomes a new array item). On the other hand, if you overwrite the corresponding lead fields each time, the CRM sync can be lossy.

Check my last answer here too.

Anonymous
Not applicable

Re: Custom object data via token

Yeah. humm interesting. The integration is able to write to the CO and lead field at the same time so plan A is good to go.

I am curious about your approach though. How would I be able to parse that to do a data value change or is it all via webhook(FlowBoost)?

var jsonArray = {{lead.JSON array}},

      lastEvent = jsonArray[jsonArray.length - 1];

return lastEvent["eventID"];

Sorry, never used webhooks. How does that return statement change the value of a field for that lead, say {{lead.Event ID}}?

SanfordWhiteman
Level 10 - Community Moderator

Re: Custom object data via token

I'd say it all depends on how/where (and how easily) you want to write, read, action, and report on the data.

Marketo Flow steps (on their own) can assemble JSON arrays of objects, given a single object as input, say, from a form post. You need three steps/fields:

  • last​Object is a single object
      • { "key1" : "value1", "key2", "value2" }
  • intermediateListOfObjects is the typical comma-delimited history field using Change Data Value
      • ​{{Lead.LastObject}} , {{Lead.intermediateList}}
  • ​arrayOfObjects ​to the value of intermediateObjectList, wrapped in [] so it's now a valid JSON array
      • [ {{Lead.intermediateObjectList}} ]

Certainly it's easier to use FlowBoost because it's JSON-fluent (you wouldn't need the intermediate list). But it's possible to write an append-only JSON field without FB.

In your example, you're reading a single property ("eventID") off the last event in the array. That would result in a webhook response like this:

{

  "response" : 12345

}

I don't know exactly what you want to do with the response, though.  You don't have to map it back to a lead field, since you can use the ​Webhook is Called ​trigger to take action on the contents of the response without actually saving the contents.  This is an efficient way to avoid creating extra fields.

Anonymous
Not applicable

Re: Custom object data via token

That is awesome! I am going to play around with this in sandbox, thanks for taking the time to explain. Very much appreciated!

Amanda_Thomas6
Level 9

Re: Custom object data via token

Can you access tokens in the email editor setting? I'm trying to use a few fields form the custom object in an email alert. object is "RV Member". I would think token looks like {{RV Member.Phone}}, but I can't find the token within the email editor. (When you go to insert token, and search the dropbox.) Would I just type that into the email?