I have a Smart Capture form that is used to capture opt-ins for Salesforce Contacts. I want the form to use the contact's first name and phone number to find the person's Contact ID and then put the contact ID into the data extension tied to the Smart Capture form.
I have the below code, but it's not finding a Contact ID even though a Contact ID exists.
%%[
var @subscriberRows
set @subscriberRows = RetrieveSalesforceObjects(
"Contact",
"ID,FirstName",
"phone", "=", @phonenumber,
"FirstName", "=", @FirstName )
if RowCount(@subscriberRows) == 1 then /* there should only be one row */
var @subscriberRow, @firstName, @lastName, @phonenumber
set @subscriberRow = Row(@subscriberRows, 1)
set @firstName = Field(@subscriberRow, "FirstName")
set @lastName = Field(@subscriberRow, "LastName")
set @phonenumber = Field(@subscriberRow, "phonenumber")
/* Update Data Extension with Contact ID */
InsertDE("SMS_Optin_test", "FirstName", @firstName, "LastName", @lastName, "PhoneNumber", @phoneNumber, "ContactID", @contactID)
else
/* Contact not found */
set @contactID = "error"
endif
]%%