10 Replies Latest reply on Jun 14, 2017 12:40 PM by Sanford Whiteman

    Custom object data via token

    Tony T

      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?

        • Re: Custom object data via token
          Sanford Whiteman

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

          1 of 1 people found this helpful
            • Re: Custom object data via token
              Tony T

              Well that's a bummer.

               

              Thanks for the quick response.

                • Re: Custom object data via token
                  Sanford Whiteman

                  What are you trying to do exactly?

                    • Re: Custom object data via token
                      Tony T

                      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.

                        • Re: Custom object data via token
                          Sanford Whiteman

                          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.

                            • Re: Custom object data via token
                              Tony T

                              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}}?

                                • Re: Custom object data via token
                                  Sanford Whiteman

                                  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:

                                   

                                  • lastObject 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.

                                  2 of 2 people found this helpful
                      • Re: Custom object data via token
                        Amanda Thomas

                        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?