0

I am trying to display a value of "Yes" or "No" depending on if a checkbox is checked. If checked, I want to display "Yes" if not, display "No".

I have tried a few variants of the following code, but have not been able to get it to work. set

%%[var @rs2 Set @rs2= RetrieveSalesforceObjects('Reservation__c', 'SPF14_Purchased__c','Household__c','=', @ID)

set @row=row(@rs2,1) set @SPF14=field(@row,'SPF14_Purchased__c')

%%[IF (@SPF14 == True) THEN ]%% %%[ SET @SPF14 = Yes' ]%%

%%[ELSEIF (@SPF14 == False) THEN]%% %%[SET @SPF14 = 'No']%% %%[ELSE]%% %%[ENDIF]%% ENDIF ]%%

3
  • Try true and false instead of "true” and "false”. It’s hard to troubleshoot the rest of your script, as it seems incomplete
    – zuzannamj
    Jun 19, 2020 at 22:53
  • I tried true and false and that did not work. I added the rest of the script in my original question. Thank you for your quick response.
    – Dalbanes
    Jun 19, 2020 at 23:02
  • You have a variable @ID which is not set. And you could put all that script in one block, but that’s not the issue here
    – zuzannamj
    Jun 19, 2020 at 23:13

1 Answer 1

0

You have 2 endif however only one if is set. You should delete the additional endif in the end. Also your code is all ampscript and therefore 1 ampscript block should be used. Also ' was missing before the yes value. As zuzannamj metioned the @ID parameter is not defined. You should set it before using it to reterive the object from SF.

See fixed code below:

%%[

set @ID='Value should be inserted here' 
set @rs2= RetrieveSalesforceObjects('Reservation__c', 
'SPF14_Purchased__c','Household__c','=', @ID)
set @row=row(@rs2,1) 
set @SPF14=field(@row,'SPF14_Purchased__c')

IF (@SPF14 == 'True' ) THEN 

SET @SPF14 = 'Yes' 
ELSEIF (@SPF14 == 'False' ) THEN 
SET @SPF14 = 'No' 

ENDIF

]%%
1
  • Thank you Barak. Your recommendations were great. I did have to use double quotes ("yes" and "No") to get them to display. Thank you!
    – Dalbanes
    Jun 22, 2020 at 22:42

You must log in to answer this question.

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