0

I'm trying to personalize an SMS in a journey but the SMS isn't sending. If I leave out the code, it works. To set up the code, I'm using data from the Entry Source "Test_B2C_Contracts_Renewals". If it's possible, once the code works, I would use a different entry source "B2C_Customers", but the 2 data extensions are linked through Attribute Group (So I'm not sure if it will still work).

The code I put in the message field of the SMS so far (that I found here on stackexchange and adapted to our needs):

%%[ 

SET @idSubscriber = MOBILE_NUMBER 
SET @rows = LookupRows("Test_B2C_Contracts_Renewals","BankAccountNumber","OfferAmount","CodeVCS","GSM1",@idSubscriber) 
SET @RowCount = RowCount(@rows) 

IF (Rowcount(@rows) > 0) THEN 
    SET @ILRow = row(@rows,1) 
    SET @BankAccountNumber = Field(@ILRow,"BankAccountNumber")
    SET @OfferAmount = Field(@ILRow,"OfferAmount")
    SET @CodeVCS = Field(@ILRow,"CodeVCS")
ENDIF 

]%%

BankAccountNumber: %%=Field(@ILRow,"BankAccountNumber")=%%, 
Amount %%=Field(@ILRow,"OfferAmount")=%%, 
communication %%=Field(@ILRow,"CodeVCS")=%%. Info on our website.
1

What SF Support says does make it work, but you're setting variables and then never using them. And, why not catch the condition where no rows get returned?

I'd adjust it like this:

%%[ 

SET @idSubscriber = MOBILE_NUMBER 
SET @rows = LookupRows("Test_B2C_Contracts_Renewals", "GSM1", @idSubscriber) 
SET @RowCount = RowCount(@rows) 

IF @rowCount > 0 THEN 
    SET @row = row(@rows,1) 
    SET @BankAccountNumber = Field(@row,"BankAccountNumber")
    SET @OfferAmount = Field(@row,"OfferAmount")
    SET @CodeVCS = Field(@row,"CodeVCS")
    output(concat("BankAccountNumber: ", @BankAccountNumber, ", Amount: ", @OfferAmount, ", Communication: ", @CodeVCS, ". Info on our website."))
else
    output(concat("No renewal found."))
ENDIF 

]%%
  • Thanks Adam, that worked like a charm too. I'm completely new to AMPscript, so I'm discovering it as we go :) – David van den broeck May 28 '18 at 6:50
0

I received a correction from the code by the SF Support team, which worked in my case.

%%[ 
SET @idSubscriber = MOBILE_NUMBER 
SET @rows = LookupRows("Test_B2C_Contracts_Renewals","GSM1",@idSubscriber) 
SET @RowCount = RowCount(@rows)
IF (Rowcount(@rows) > 0) THEN 
SET @ILRow = row(@rows,1) 
SET @BankAccountNumber = Field(@ILRow,"BankAccountNumber") 
SET @OfferAmount = Field(@ILRow,"OfferAmount") 
SET @CodeVCS = Field(@ILRow,"CodeVCS")
ENDIF 
]%% 

BankAccountNumber: %%=Field(@ILRow,"BankAccountNumber")=%%, Amount %%=Field(@ILRow,"OfferAmount")=%%, communication %%=Field(@ILRow,"CodeVCS")=%%. Info on our website.
0

Change the last part to this

BankAccountNumber: %%=v(@BankAccountNumber)=%%, 
Amount %%=v(@OfferAmount)=%%, 
communication %%=v(@CodeVCS)=%%.

Displaying the variables instead of calling them again from DE

  • Please add detail like what change you did and why. This is flagged for deletion. – Mr.Frodo May 25 '18 at 11:07
  • Added more detail – sfdcFanBoy Jul 11 '18 at 5:37

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.