I am using the following code to select a contact. If Resort General Manager field is blank, then use Resort General Manager field. I have tried a couple of variations, but cannot display Regional manager if it is blank or it will always display the regional manager.


var @rs9,@regmgr,@genmgr
Set @rs9= RetrieveSalesforceObjects('Reservation__c','Resort_General_Manager__c, Resort_Regional_Manager__c', ' Household__c', '=' , @ID)

set @row=row(@rs9,1)
set @genmgr=field(@row,'Resort_General_Manager__c')
set @regmgr=field(@row,'Resort_Regional_Manager__c')

%%[if not empty(@genmgr)then]%% 




2 Answers 2


I can see that ampscript blocks are not closed properly. Also, am not sure how you are getting the @Id value. I have just used Id as subscriberkey. Below is the updated code.

%%[var @rs9,@regmgr,@genmgr 
Set Id = Attributevalue("_subscriberkey")
Set @rs9= RetrieveSalesforceObjects('Reservation__c','Resort_General_Manager__c,Resort_Regional_Manager__c',' Household__c','=', @ID)
set @row=row(@rs9,1) 

set @genmgr=field(@row,'Resort_General_Manager__c ') 
If empty(@genmgr) Then
set @regmgr=field(@row,'Resort_Regional_Manager__c ')
set @regmgr=field(@row,'Resort_General_Manager__c ') 

You can use this %%=v(@regmgr)=%% value in In-line HTML.

Let me know if this helps.

  • Naveen, that worked great. Thank you.
    – Dalbanes
    Jun 1, 2020 at 15:48
  • You are welcome @Dalbanes !
    – Naveen VM
    Jun 1, 2020 at 16:17

To simplify your output, you could set both at top then use an inline if to set the correct output in another var.

Something like:

Set @id = /* your id field */

Set @rs9= RetrieveSalesforceObjects('Reservation__c','Resort_General_Manager__c, Resort_Regional_Manager__c', ' Household__c', '=' , @ID) 

Set @row = row(@rs9,1) 

set @genmgr = field(@row,'Resort_General_Manager__c') 

set @regmgr = field(@row,'Resort_Regional_Manager__c') %%

Set @mgr = iif(EMPTY(@genmgr), @regmgr,@genmgr)

You manager is %%=v(@mgr)=%%

Which will output general mgr if value otherwise it will output regional mgr. This way you need not worry about mucking up your output areas with if statements potentially requiring duplicate content.

You must log in to answer this question.

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