0

I have an email in Marketing Cloud in which I want to get the contact owner's name to show up at the bottom in the signature. First I used the Lookup function and when I verify and test the email it works fine, but when I add it to the journey, I get a cancellation triggered send with error:

ExactTarget.OMM.InvalidScriptException: An error occurred when attempting to resolve a function call. See inner exception for detail. Function Call: Lookup('User_Salesforce','Email','Id',Retention_Owner__c)

The second method I tried was using AMPscript. With this, it's the same issue, where the email works in verify and test, and when I validate the journey, I get an error:

Error 1: Script SET Statement Invalid An error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: RetrieveSalesforceObjects('User','Id,Name', 'Id', '=', Retention_Owner__c)

The code is below:

For lookup I used: %%=Lookup('User_Salesforce','Email','Id',Retention_Owner__c)=%%

where User_Salesforce is the synchronized DE

and for AMPscript I used:

%%[
  VAR @rs, @row, @value
  SET @rs = RetrieveSalesforceObjects('User','Id,Name', 'Id', '=', Retention_Owner__c)

  IF RowCount(@rs) == 1 THEN
    SET @row = Row(@rs, 1)
    SET @value = Field(@row, 'Name')
  ELSE
    SET @value = 'Fallbackvalue'
  ENDIF

]%%

%%=v(@value)=%%

Could anyone point out what I doing wrong here?

0

The error indicates that Retention_Owner__c doesn't exist in your send context. Is it part of your entry source? If not, you'll need to ensure you retrieve that value in your scripting first.

You can handle this situation defensively by using the AttributeValue function, which will return an empty string if it doesn't exist:

%%[

  VAR @rs, @row, @value, @ro

  set @ro = AttributeValue("Retention_Owner__c")
  SET @rs = RetrieveSalesforceObjects('User','Id,Name', 'Id', '=', @ro)

  IF RowCount(@rs) == 1 THEN
    SET @row = Row(@rs, 1)
    SET @value = Field(@row, 'Name')
  ELSE
    SET @value = 'Fallbackvalue'
  ENDIF

]%%

%%=v(@value)=%%
| improve this answer | |
  • Hi @AdamSpriggs, thank you for your help, with your tweak, I do get the email now, but it always goes into the else loop and return the 'Fallbackvalue' instead of the Retention Owner name.I tried adding in a delay of an hour and also tried using an old contact that had its retention owner a few days ago. In the preview and test for the email if I choose that contact the values populate correctly. What do you think could be causing the issue? – Rohit Sep 8 at 19:41

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.