0

I have a cloudpage which collects information by html form to DE. I have SubscriberKey, EmailAddress, FirstName, LastName, Study_Program_Type, Date_time, ContactId, Program_Duration columns and subscriberkey is auto-generated by GUID(). However, I need to Create an automation which will process responses once per day in order to make sure those responses are sent back to Salesforce. If contact with such email already exists - update it. If not - create a new one. Add contact Id next to the corresponding record in the original DE in MC.

I have decided to use script activity so that I can call ampscript by ContentBlockByID function. I receive somehow error. I am testing on cloud page. Cloudpage code which also exists in script activity:

<script runat="server">
    try {
        var stream = Platform.Function.ContentBlockByID("224694");
    } catch (e) {
        Write("Error: " + Stringify(e));
    }
</script>
%%[
var @email, @subscriberRows, @rowCount, @ContactId
SET @firstName = AttributeValue('FirstName')
SET @lastName = AttributeValue('LastName')
SET @studyProgram = AttributeValue('Study_Program_Type')
SET @duration = AttributeValue('Program_Duration')
set @email = AttributeValue("EmailAddress")
set @ContactId = AttributeValue("ContactId")
set @subscriberRows = LookupRows("EF_Gokce_TriggeredSend", "EmailAddress", @email)

if RowCount(@subscriberRows) > 0 then

 SET @existingContactRows = RetrieveSalesforceObjects(
     "Contact",
     "Id",
     "Email", "=", @email
 )

 if RowCount(@existingContactRows) == 1 then
     SET @existingContactRow = Row(@existingContactRows, 1)
     SET @existingContactId = Field(@existingContactRow, 'Id')
     UpdateData("EF_Gokce_TriggeredSend", 1, "ContactId", @existingContactId)
     SET @updateResult = UpdateSingleSalesforceObject(
         "Contact",
         'Id', @existingContactId,
         'FirstName', @firstName,
         'LastName', @lastName,
         'Email', @email,
         'Study_Program_Type__c', @studyProgram,
         'Program_Duration__c', @duration
     )
 ELSE

     SET @createResult = CreateSalesforceObject(
         "Contact",
         5,
         'FirstName', @firstName,
         'LastName', @lastName,
         'Email', @email,
         'Study_Program_Type__c', @studyProgram,
         'Program_Duration__c', @duration
     )
 endif

endif
]%%

and the error code ** Error: {"message":"An error occurred when attempting to evaluate a ContentBlockByID function call.\r\n Function Call: ContentBlockByID(224694)\r\nSee inner exception for details.","description":"ExactTarget.OMM.FunctionExecutionException: An error occurred when attempting to evaluate a ContentBlockByID function call.\r\n Function Call: ContentBlockByID(224694)\r\nSee inner exception for details.\r\n Error Code: OMM_FUNC_EXEC_ERROR\r\n - from Jint --> \r\n\r\n --- inner exception 1---\r\n\r\nExactTarget.OMM.OMMException: An error occurred when attempting to parse HtmlEmailBody content for HTML content.\r\n MemberID: 100013654\r\n JobID: 0\r\n ListID: 0\r\n Content Begins With: \r\n\r\n --- inner exception 2---\r\n\r\nExactTarget.OMM.OMMException: An error occurred when attempting to parse HtmlEmailBody content for HTML content.\r\n MemberID: 100013654\r\n JobID: 0\r\n ListID: 0\r\n Content Begins With: \r\n\r\n SET @existingContactRows = RetrieveSalesforceObjects(\r\n "Contact",\r\n "Id",\r\n \r\n Error Code: OMM_VAR_SET_EXPR_INVALID\r\n - from OMMCommon --> \r\n\r\n --- inner exception 3---\r\n\r\nExactTarget.OMM.OMMException: An error occurred when attempting to parse HtmlEmailBody content for HTML content.\r\n MemberID: 100013654\r\n JobID: 0\r\n ListID: 0\r\n Content Begins With: \r\n SET @existingContactRow = Row(@existingContactRows, 1)\r\n SET @existingContactId = F\r\n Error Code: OMM_VAR_SET_EXPR_INVALID\r\n - from OMMCommon --> \r\n\r\n --- inner exception 4---\r\n\r\nExactTarget.OMM.InvalidScriptException: The SET variable value expression is invalid. See inner exception for detail.\r\n Script: SET @updateResult = UpdateSingleSalesforceObject(\r\n "Contact",\r\n 'Id', @existingContactId,\r\n 'FirstName', @firstName,\r\n 'LastName', @lastName,\r\n 'Email', @email,\r\n 'Study_Program_Type__c', @studyProgram,\r\n 'Program_Duration__c', @duration\r\n )\r\n Variable Name: @updateResult\r\n Index: 1073\r\n ListID: 0\r\n Error Code: OMM_VAR_SET_EXPR_INVALID\r\n - from OMMCommon --> \r\n\r\n --- inner exception 5---\r\n\r\nExactTarget.OMM.InvalidScriptException: An error occurred when attempting to resolve a script expression. See inner exception for detail.\r\n Script Expression: UpdateSingleSalesforceObject(\r\n "Contact",\r\n 'Id', @existingContactId,\r\n 'FirstName', @firstName,\r\n 'LastName', @lastName,\r\n 'Email', @email,\r\n 'Study_Program_Type__c', @studyProgram,\r\n 'Program_Duration__c', @duration\r\n )\r\n MemberID: 100013654\r\n JobID: 0\r\n Error Code: OMM_SCRIPT_SYNTAX_ERR\r\n - from OMMCommon --> \r\n\r\n --- inner exception 6---\r\n\r\nExactTarget.OMM.InvalidFunctionException: The function call includes an invalid number of repeating parameters. Repeating parameters must be included in full sets.\r\n Function Call: UpdateSingleSalesforceObject(\r\n "Contact",\r\n 'Id', @existingContactId,\r\n 'FirstName', @firstName,\r\n 'LastName', @lastName,\r\n 'Email', @email,\r\n 'Study_Program_Type__c', @studyProgram,\r\n 'Program_Duration__c', @duration\r\n )\r\n Function Name: UpdateSingleSalesforceObject\r\n Number of Parameters in Repeating Set: 2\r\n Number of Repeating Parameters in Call: 11\r\n Number of Invalid Repeating Parameters in Call: 1\r\n Error Code: OMM_FUNC_SYNTAX_ERR\r\n - from OMMCommon\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"} **

Could you please help me where I do mistake

1 Answer 1

1

I think the problem is related to UpdateSingleSalesforceObject function in your code. You don't need to specify the name of the Id column that will be used to identify the contact. It should look like this:

SET @updateResult = UpdateSingleSalesforceObject(
         "Contact",
          @existingContactId,
         'FirstName', @firstName,
         'LastName', @lastName,
         'Email', @email,
         'Study_Program_Type__c', @studyProgram,
         'Program_Duration__c', @duration
     )

The second parameter of the function is the ID of the record to update.

Reference: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-salesforce/mc-ampscript-reference-salesforce-update-single-object.html

4
  • Thank you soo much! Jan 31 at 14:47
  • but when I run the script, I cannot see contact ID on DE. I have added email address which is already exists in sf side :( Jan 31 at 14:53
  • Does the record already exist in EF_Gokce_TriggeredSend DE? If not, you might need to replace UpdateData function with UpsertData to insert the record if it does not exist in the DE.. Jan 31 at 15:01
  • yes it is exists in DE and the email address exists in salesforce with a contact records Feb 1 at 8:43

You must log in to answer this question.

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