I created a Triggered Send for a Custom Object (CreditFlow__c) in SFDC to be send via MC Connect. Without any personalization the email is sent successfully, but when adding personalization things get complicated.

We need to retrieve the Lead name and other values from the Lead object to be used in the email, as well as other values that exist in the CreditFlow__c object. To do so, we are using RetrieveSalesforceObjects to first obtain the Lead ID from the CreditFlow__c object, and use that to do another RetrieveSalesforceObjects to the Lead object and pull the Name. However, the call returns empty values, and we get the following error message when validating this via a CloudPage:

{"message":"Invalid row (parameter 1) passed to Field function. Row is null or empty.\r\n Function: FIELD(@Casorow,\"ID_Prospecto__c\")","description":"ExactTarget.OMM.FunctionExecutionException: Invalid row (parameter 1) passed to Field function. Row is null or empty.\r\n Function: FIELD(@Casorow,\"ID_Prospecto__c\")\r\n Error Code: OMM_FUNC_EXEC_ERROR\r\n - from Jint\r\n\r\n"}

Here's a link to the code I have: https://codeshare.io/G7keej

When inserting this in an email and visualizing it in the configuration of the Trigger in SFDC we get a "400 Bad Request" error.

If I output the values for Sobject and RecordId I get empty values as well. Any ideas??

1 Answer 1


As the error message indicates, there is no record in the rowset returned in your @Caso rowset.

This could be caused by one of the following scenarios:

  1. The SObject is not available in Sales Cloud
  2. There isn't a matching RecordId value in your Sendable Data Extension
  3. The SObject or RecordId fields don't appear in your Sendable Data Extension

I'd suggest building in some exception handling to handle this scenario like you have done with the second rowset.

Additionally, you are retrieving the Id field from the Lead object, but you haven't explicity included this in the second argument. Refer to updated code below.

While this will work, I would advise against using RetrieveSalesforceObjects function in an email if you are sending to a large number of Subscribers, as the function can be very slow (approx 2-3 seconds per retrieve — for a send of >1m records, I calculated it would take 1.5 years for the email to send!). Instead, you may want to consider syncing the objects as Synchronized Data Extensions and using the LookupRows function to retrieve your rowset, which will be a lot more performant (but this is only an option if the object record was created >15 minutes ago).

var @mySObject, @myRecordId, @Caso, @CasoRow, @CasoIDLead, @Lead, @Name, @Email

Set @mySObject = AttributeValue("SObject")
Set @myRecordId = AttributeValue("RecordId")

Set @Caso = RetrieveSalesforceObjects(@mySObject, "Id, ID_Prospecto__c", "Id", "=", @myRecordId)

if RowCount(@Caso) > 0 then

   Set @CasoRow = Row(@Caso,1)
   Set @CasoIDLead = FIELD(@Casorow,"ID_Prospecto__c")


   RaiseError('no matching rows found for ID_Prospecto__c', true)


Set @Lead = RetrieveSalesforceObjects("Lead", "Id,Name,Email", "Id", "=", @CasoIDLead)

if RowCount(@Lead) > 0 then

   Set @LeadRow = Row(@Lead, 1)
   Set @LeadID = FIELD(@LeadRow, "Id")
   Set @Name = FIELD(@LeadRow, "Name")
   Set @Email = FIELD(@LeadRow, "Email")


   RaiseError('no matching rows found for Lead Id', true)


output(concat("<br>rowCount: ", @rowCount))
output(concat("<br>Name: ", @Name))
output(concat("<br>LeadID: ", @LeadID))
output(concat("<br>Email: ", @Email))



After reviewing this issue on a call with Esteban, I identified that the Data Extension field names in the Triggered Send DE were incorrect (e.g. scenario #3 was the issue), as they used the field names mySObject and myRecordId. Updating these field names to the correct values fixed this issue.

FYI, when using a Salesforce Triggered Send, if you add the fields SObject and RecordId to your Triggered Send Data Extension (like Esteban has done) then these fields will be automatically populated with the respective object name and record Id, so you can then use these values as arguments in AMPscript functions.

  • Hi Eliot! thanks so much for your answer. I wasn't able to get back to this up until today. I copied the updated code into my email, but I'm still getting "400 - Bad Request" when trying to previsualize the email inside the Trigger in SFDC. What's strange is that when trying to just output the values from SObject and RecordId I get empty/null values. I do have a Triggered Send DE with those 2 fields setup as well. I'm afraid using SyncDE's is not really an option, due to the limited contacts they have in SFMC. Dec 15, 2020 at 18:40
  • @EstebanJoséAlvarado It would help to see this code in context to debug this further. Please can you schedule a call at calendly.com/eliotharper/30min so we can review together? Dec 15, 2020 at 19:19
  • Done! Thanks a lot Eliot! Dec 15, 2020 at 19:51
  • 1
    @EstebanJoséAlvarado I've added the solution based on your specific issue! Dec 16, 2020 at 20:58
  • Perfect! Thank you very much for your help, Eliot! Dec 16, 2020 at 21:04

You must log in to answer this question.

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