I have a sign up form that upon submission will create a PersonAccount (Account) record in Salesforce. I then want to create the corresponding Contact in SFMC so that we have the values until it syncs over with the connector.
Straight after I have created the Account record with CreateSalesforceObject() I then use RetrieveSalesforceObjects() with the AccountId to try and get the PersonContactId:
/*Retrieve PersonContactId*/
set @accountRows = RetrieveSalesforceObjects(
"Account",
"PersonContactId",
"Id", "=", @createAccount)
if RowCount(@accountRows) == 1 then /* there should only be one row */
var @subscriberRow, @PersonContactId
set @subscriberRow = Row(@subscriberRows, 1)
set @PersonContactId = Field(@subscriberRow, "PersonContactId")
endif
However I get the below error message indicating that the PersonContactId value is null.
Invalid row (parameter 1) passed to Field function. Row is null or empty.\r\n Function: Field(@accountRow, "PersonContactId\
This was leading me to assume that the code is querying too quick, before SF has had chance to create all the attributes.
However, I have moved the RetrieveSalesforceObjects to a second cloud page that I redirect to, and also used the SSJS function sleep(milliseconds) to create a 3 second delay. But I am still encountering the issue.