[SalesForce] Create Salesforce Object through Marketing Cloud landing page

I'm trying to create a custom Salesforce object (in the Salesforce account integrated with my Marketing Cloud account) when people visit my Marketing Cloud landing page.

However I keep getting a 500 error on the page.

I have one variable in the Create Salesforce Object string which I've already set on the page. I've also used that variable to pre-fill a field in a smart capture form on the page, I've tested that bit and its working.

  • The Custom object name is: NPS_survey (or API name: NPS_Survey__c)
  • The record Type ID is: 012w0000000V749AAC
  • The variable ordinal (field: NPS_Survey__c:Account_Name__c) is: ContactName
  • I want to fill the NPS_Survey_Score__c field with the '1'

Here's what i have:

%%[ var @id
set @id=CreateSalesforceObject("NPS_Survey", 3,
"RecordType","012w0000000V749AAC",
"NPS_Survey__c:Account_Name__c",=v(@ContactName)=,
"NPS_Survey_Score__c","1") ]%%

I've tried different variances of the variable, such as including/not including quotation marks, the =/@/v signs etc with no luck.

Best Answer

v is used outside the ampscript block to print the output of the variable. you cannot use inside the ampscript block. Instead, define a variable and call that variable in the CreateSalesforceObjectfunction. Very first parameter of this function is the object name if it's the custom object then you should use the API name of the object else the code will throw an error

%%[ 
var @id
set @id = CreateSalesforceObject("NPS_Survey__c", 3, "RecordType", "012w0000000V749AAC" , "Account_Name__c",@ContactName, "NPS_Survey_Score__c","1") 
]%%
Related Topic