1

I have a question. I have two options of SMS message creating

  1. Use AMPscript like in email building
%%[
var @fname
set @fname = [First_Name__c]
%%]
%%=v(@fname)=%%
%%[
var @row, @rows, @fname
set @rows = LookupOrderedRows("SMS",1,"StartDateTime desc", "Phone__c", MOBILE_NUMBER)
set @row = row(@rows,1)
set @fname = field(@row,"First_Name__c")
%%]
%%=v(@fname)=%%

Why for the first option SMS didn't come but for the second it came? Journey settings for both variants were equal. Or why we cant use 1st option for sms message?

1
  • Please update your question to include some details about your journey entry event. Commented Jan 13, 2023 at 18:48

1 Answer 1

2

The First_Name__c must be in your send context for the personalization string to be valid. You can use AttributeValue to validate existence of the contextual string. This'll illustrate the function by returning Friend if First_Name__c cannot be found.

%%[

set @fname = AttributeValue("First_Name__c")
set @fname = iif(empty(@fname), "Friend", @fname)

]%%
%%=v(@fname)=%%

In the second one, MOBILE_NUMBER is a system string that's present in the send context. It's available since it's bound in Contact Builder. I'd update your code to have a fallback value as well:

%%[

set @rows = LookupOrderedRows("SMS",1,"StartDateTime desc", "Phone__c", MOBILE_NUMBER)

if rowcount(@rows) > 0 then
  set @row = row(@rows,1)
  set @fname = field(@row,"First_Name__c")
else
  set @fname = "Friend"
endif

]%%
%%=v(@fname)=%%
2
  • Thank you for the answer!
    – Bob Greed
    Commented Jan 14, 2023 at 11:46
  • About journey entry event - it is "Salesforce Data"
    – Bob Greed
    Commented Jan 14, 2023 at 11:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .