I'm trying to fetch the data from SalesCloud. The codes currently are hosted in CloudPages, and I'm using the SFMC test sent from the email in Content Builder to pass the subscriber details to the cloud pages.
This is the CTA from the email:
<a href="%%=CloudPagesURL(1663)=%%" style="color: #426BB3; text-decoration:none;" target="blank">Manage Preferences</a>
And, this is the full code in the cloudPages:
<script runat="server">
Platform.Load("Core","1.1.1");
try{
</script>
%%[
SET @contactId = _subscriberkey
IF NOT EMPTY(@contactId) THEN
/* fetch data from Sales Cloud to show in the form */
SET @subscriberRows = RetrieveSalesforceObjects(
"Contact",
"Id,FirstName,LastName,Email,HasOptedOutOfEmail",
"Id", "=", @contactId
)
IF RowCount(@subscriberRows) > 0 THEN
SET @row = row(@subscriberRows,1)
SET @FirstName = field(@row,"FirstName")
SET @LastName = field(@row,"LastName")
SET @Email = field(@row,"Email")
SET @HasOptedOutOfEmail = field(@row,"HasOptedOutOfEmail")
]%%
<h2>Update your profile:</h2>
<form action="%%=RequestParameter('PAGEURL')=%%" method="post">
<label>First name: </label><input type="text" name="firstname" value="%%=v(@FirstName)=%%"><br>
<label>Last name: </label><input type="text" name="lastname" value="%%=v(@LastName)=%%"><br>
<label>Email: </label><input type="text" name="email" value="%%=v(@Email)=%%"><br>
</form>
%%[ELSE]%%
Errors: No records found!
%%[ENDIF ELSE]%%
Errors: Mmissing subscriber key!
%%[ENDIF]%%
<script runat="server">
}
catch(e) {
Variable.SetValue("errorMessage", Stringify(e.message) + Stringify(e.description));
}
</script>
<script runat="client">
console.log(`%%=v(@errorMessage)=%%`);
</script>
But, it's currently returning this error from the console:
"Call to retrieve records for salesforceobject Contact failed! Error in the application.
API Fault: Salesforce.com Fault thrown.
Exception Type:UnexpectedErrorFault
Exception Code:INVALID_QUERY_FILTER_OPERATOR
Exception Message:
HasOptedOutOfEmail FROM Contact WHERE Id = 'xxx.yyy@example.com.au'
^
ERROR at Row:1:Column:74
invalid ID field: xxx.yyy@example.com.au""ExactTarget.OMM.FunctionExecutionException: Call to retrieve records for salesforceobject Contact failed! Error in the application.
API Fault: Salesforce.com Fault thrown.
Exception Type:UnexpectedErrorFault
Exception Code:INVALID_QUERY_FILTER_OPERATOR
Exception Message:
HasOptedOutOfEmail FROM Contact WHERE Id = 'xxx.yyy@example.com.au'
^
ERROR at Row:1:Column:74
invalid ID field: xxx.yyy@example.com.au
Error Code: RETRIEVESFOJBECTS_FUNC_ERROR
- from Jint
"
Anyone has idea what could go wrong in here? Perhaps in the Salesforce setup?
Thanks,