1

I need to send dynamic email to all my booking contacts using AMP Script. Using FOR loop makes repetitive content. I am pulling contacts from Salesforce reports directly without using Salesforce Data Extension.

1) Any way to display content respective to each record (Dynamically)

2) Can we directly get Opportunity columns present in SF reports to Normal Data Extension? Like we can do for Contact,Account & Leads

3) Any way to uniquely identify each opportunity records?

AMP Script:

%%[ Var@fname,@AccountName,@PictureDay,@AccountPhone,@BookingOwner,@BookingOwnerEmail,@bookingdetail,@Accountid
Set @Accountid = AccountId
Set @fname=FirstName
Set @AccountName=AccountName
Set @AccountPhone=Account:Phone
Set @bookingdetail = RetrieveSalesforceObjects("Opportunity","Picture_Day__c,OwnerName__c,OwnerEmail__c","Picture_Day__c","=","2016-06-25","CloseDate","!=","2015-10-03")
For @i=1 TO RowCount(@bookingdetail) DO
Set @limitRow = Row(@bookingdetail, @i)
Set @PictureDay = Field(@limitRow,'Picture_Day__c')
Set @Bookingowner = Field(@limitRow,'OwnerName__c')
Set @BookingOwnerEmail = Field (@limitRow,'OwnerEmail__c')
]%%

Dear %%=v(@fname)=%%, 
We are looking forward to taking photographs at %%=v(@AccountName)=%% on
%%=v(@PictureDay)=%%.The phone number we have
on file for you is %%=v(@AccountPhone)=%%.

Your Account Manager is %%=v(@Bookingowner)=%% and
you can reach them at %%=v(@BookingOwnerEmail)=%%.
%%[NEXT @i]%%

Thanks,

Mitesh

2
  • What error are you currently getting?
    – 0xsegfault
    Commented Jun 28, 2017 at 20:16
  • I am not getting any error. But i am getting only the first record when i used RetrieveSalesforceObject without for loop. If i use For loop then the Content of Email also gets repeated. Hope you are getting my point? Commented Jun 30, 2017 at 5:39

1 Answer 1

0

Based on my understanding of your code, and on your description of what you would like to achieve, then you are approaching this from the wrong level.

As i understand it, essentially, you need to send an email per booking (not per contact), and this is what is causing the error you are experiencing. To directly answer your questions:

  1. Yes you can display dynamic content per record (but it doesn't seem like this is what you are trying to do - dynamic would mean if opportunity type is "VIP", show this content)
  2. You can get the opportunity records - either by importing a report or by using SQL towards the Opportunity_Salesforce synchronised DE
  3. Yes - but here it depends on the solution you desire. I believe you have a few options available.

Option 1:
Split your email into "account details" and "opportunity details" - and then present the format of the email in a way where account info is the "generic info" and the opportunity is looped over to display the bookings available in a meaningful way. E.g. a table with all bookings.

Here you need to ensure that you filter away the bookings that have already passed or that meet relevant criteria.

Option 2:
You could import / sql create the records in a data extension, and then use the fields found in the data extension (so no lookup towards salesforce) and then send an email (that isn't de-duped), this will essentially send 1 email per booking, and the email would only contain the bookings details.

Option 3
The most elegant way, potentially, would simply be to use Journey Builder and a Salesforce Data Entry Event, where you inject people when the booking record in saleforce meets the right criteria. This will also send out an email per booking, and if you include all the fields in the data extension, you do not have to lookup the information in salesforce (unless a lot of time elapses from injection to email sent, and you need to ensure you have the latest details)

Hopefully one of options are aligned with what you are trying to achieve?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .