1

I've got this code segment in an SFMC cloud page:

 set @contactIDcheck      = RetrieveSalesforceObjects('Contact', 'id, Only_Send_Monthly_Newsletter__c', 'Id', '=', @subscriberKeyForSSJS) 
    IF (RowCount(@contactIDcheck) >= 1) THEN
      set @rowContactIDcheck     = ROW(@contactIDcheck, 1)
      set @contactIDMatch           = FIELD(@rowContactIDcheck, "Id")
      set @Only_Send_Monthly_Newsletter__c = FIELD(@rowContactIDcheck, "Only_Send_Monthly_Newsletter__c")
    ]%%

    %%[ ELSE ]%%
    Hello 
    %%[
    ENDIF

Once I publish the cloud page, and then I click on the link, it only works for when the parameter we're passing @subscriberKeyForSSJS is in the salesforce object. However, if it does not exist within the salesforce object, the page doesn't load and errors out. Does anyone know the best way/or what to do if row count is 0 (if it can't find the @subscriberKeyForSSJS in the salesforce object?

0

Try to use AMPscript's NOT EMPTY construction (vide: https://help.marketingcloud.com/en/documentation/ampscript/getting_started_with_ampscript/ampscript_201/), to check if RSO function is returning anything:

IF NOT Empty(@contactIDcheck) THEN 
      set @rowContactIDcheck = ROW(@contactIDcheck, 1)
      set @contactIDMatch = FIELD(@rowContactIDcheck, "Id")
      set @Only_Send_Monthly_Newsletter__c = FIELD(@rowContactIDcheck, "Only_Send_Monthly_Newsletter__c")
ENDIF
|improve this answer|||||
  • I tried that, but it didn't do the trick. It still errors out. I think it might be due to the fact that it can't match subscriberKeyForSSJS on the line below set @contactIDcheck = RetrieveSalesforceObjects('Contact', 'id, Only_Send_Monthly_Newsletter__c', 'Id', '=', @subscriberKeyForSSJS) IF (RowCount(@contactIDcheck) >= 1) – Shokoth Hussain Jul 27 '17 at 22:26
0

Got the issue a view days ago. Create a new formula field within Salesforce that get the contact/lead id. Reference that custom field as your comparison and it will work.

The default id will always through an error, if it cannot find an exact match.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.