1

How should I structure this AMPscript to display 1 value if empty and other if not?

%%[ 

/*Set Dynamic Image URL for Hours Field */
IF not empty (@Business_Hours__c ) THEN
  SET @HoursImgURL = "URL1" 
ELSE 
  SET @HoursImgURL = "URL2"
ENDIF

]%%

or should I use :

IF Business_Hours__c == NULL THEN?
Adam Spriggs
  • 626
  • 8
  • 23
Aaron
  • 11
  • 1
  • 3
  • 1
    You'll get a lot more eyes on your SFMC questions over at [salesforce.stackexchange.com](http://salesforce.stackexchange.com), specifically with the [marketing-cloud](http://salesforce.stackexchange.com/questions/tagged/marketing-cloud) and [ampscript](http://salesforce.stackexchange.com/questions/tagged/ampscript) tags. – Adam Spriggs Apr 13 '18 at 13:58
  • How and where are you setting `@business_hours__c`? – Adam Spriggs Apr 13 '18 at 13:59
  • This value is populated in my Data Extension (which is sendable) – Aaron Apr 13 '18 at 18:23

1 Answers1

1

The IF statement above looks fine in that it will set @HoursImgURL to "URL1" when @Business_Hours__c is not empty or "URL2" otherwise. To display that value, you would then include something like the below:

%%=v(@HoursImgURL)=%%

For example, if using within HTML, it could look like this:

<div><img src="%%=v(@HoursImgURL)=%%" /></div>
tim_schaaf
  • 249
  • 2
  • 9