Set Custom Object with Opportunity Item | Community
Skip to main content
michaelstancil
Level 3
January 26, 2022
Question

Set Custom Object with Opportunity Item

  • January 26, 2022
  • 2 replies
  • 3689 views

Hi all,

 

I'm trying to set a custom object to an email that is within an opportunity item so that I can use that newly set custom object to send a notification email via the flow step. This is because we send an email to a client with opportunity-specific info, and then we want to alert the sales rep of that email, but for other reasons, not all sales reps are on the lead level, so I need to surface them.

 

I've created a token that I've placed within the email that goes out to the client, and the referenced items are checked on the right, however, the values don't update. 

 

#set( ${OpportunityList.get(0).SalesRepEmail__c} = ${lead.CustomObjectEmail})

 

Any thoughts? 

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

2 replies

Jo_Pitts1
Community Advisor
Community Advisor
January 26, 2022

Are you expecting this to update back into the database?

If so, that won't work.  Velocity doesn't write back to the Marketo DB.

Regards

michaelstancil
Level 3
January 26, 2022

That's exactly what I was hoping...as I was going to use that new field and perform a change data value. Are there any other ways around something like this?

Jo_Pitts1
Community Advisor
Community Advisor
January 26, 2022

I'm a bit bewildered here.

Are you trying to update the Sales Rep email on the lead or on the opportunity?

What if they have more than one opportunity.

 

i.e. can you explain the use case wrt opportunities and leads please

SanfordWhiteman
Level 10
January 26, 2022

@michaelstancil I’ll let you and Jo continue with the business requirements discussion, but be aware there are problems with this code on its own:

#set( ${OpportunityList.get(0).SalesRepEmail__c} = ${lead.CustomObjectEmail})
  1. Don’t use curly braces (= ${formal} = formal references) inside directives. Use $simple notation.
  2. I have not once seen code where it’s correct to simply use the first indexed Opportunity (.get(0)) . The Opportunity list must be treated as an arbitrarily ordered list. You should be targeting a specific Opportunity based on other characteristics, such as deliberately sorting the list by a Date field or checking other field values for the matching Opportunity.
michaelstancil
Level 3
January 26, 2022

@sanfordwhiteman Thanks for the pointers, you made me realize I needed another value to key off of.

 

 

#set( $lead.CustomObjectEmail = "CATCHALL@EMAIL.COM" ) #foreach( $Opportunity in $OpportunityList ) #if( $Opportunity.VARIABLETOUPDATEAGAINST.isNotEmpty ) #set( $lead.CustomObjectEmail = $Opportunity.SalesRepEmail__c ) #break #end #end

 

 

Jo_Pitts1
Community Advisor
Community Advisor
January 27, 2022

@michaelstancil ,

this still won't work no matter HOW technically correct your code.. you can't update the lead from Velocity (hence why I didn't even get into to discussing coding with you).

 

I think you need a webhook to do this.  FlowBoost is probably a good option.

 

@sanfordwhiteman, can you see custom objects in FlowBoost?

 

Cheers

Jo