0

Do we have any specific syntax to look at specific DE for the field if it's empty or not empty?

Eg: %%[IF NOT EMPTY (@PRODUCT_CODE)IN [Data Extension] THEN]%%

I want to look only at specific DE as I'm traversing through 3 Different DE and this field has a value that is present in 2nd DE but not in 3rd DE and based on this Dynamic Content is getting populated.

Do reply if someone knows this!

    <!--BEGIN CONTENT_REGION_|Check Reorder|-->
    
    %%[
    
      var @CUSTOMER_ID, @rows1, @row1, @rowCount1, @i
      SET @CUSTOMER_ID = AttributeValue("CUSTOMER_ID")
      SET @rows1 = LookupRows("DE2","CUSTOMER_ID", @CUSTOMER_ID)
      SET @rowCount1 = rowcount(@rows1)
    
      IF @rowCount1 > 0 then
    
        FOR @i = 1 to @rowCount1 do
    
          Var @PRODUCT_CODE
    
          SET @row1 = row(@rows1, @i)  /* get row based on counter */
          SET @PRODUCT_CODE = field(@row1,"PRODUCT_CODE")
    
          IF NOT EMPTY(@CUSTOMER_ID)THEN
    
            VAR @rows2, @row2, @rowCount2, @j
            SET @rows2 = LookupRows("DE3","PRODUCT_CODE", @PRODUCT_CODE)
            SET @rowCount2 = rowcount(@rows2)
    
            IF @rowCount2 > 0 then
    
              FOR @j = 1 to @rowCount2 do
    
                var @NAME1, @NAME2, @IMAGE, @LINK, @COPYRIGHT2
                SET @row2 = row(@rows2, @j)  /* get row based on counter */
                SET @NAME1 = field(@row2,"NAME1")
                SET @NAME2 = field(@row2,"NAME2")
                SET @IMAGE = field(@row2,"IMAGE")
                Set @link = Concat('https://', @IMAGE)
                SET @LINK = Concat('https://',field(@row2,"LINK"))
                SET @COPYRIGHT2 = field(@row2,"COPYRIGHT2")
    
              next @j
    
            ENDIF
    
          ENDIF
    
        next @i
        
      ENDIF
    
    ]%%
    
    %%[IF NOT EMPTY (@PRODUCT_CODE)THEN]%%

<HTML - Dynamic Content Block>

1 Answer 1

1

Edited I shifted my example to show a scenario based off your comment. Also, if you want to see if it exists in DE3 and that is what you want to check on, you should add in the condition of

%%[IF NOT EMPTY(@PRODUCT_CODE) AND @rowcount2 > 0 THEN]%%

This way it will only run if there was a return in your LookupRows to DE3.


What you need to do is do a lookup to that data extension (assuming its not the sendable DE) to get the value. As a note, you will need to match a sendable value to the primary key in that relational Data Extension (for instance matching the sendable email address to the Email Address primary key in your relational DE).

You can then do your IF statement on the value that is assigned to that AMPscript variable.

Something like:

%%[
  SET @ProductCode = AttributeValue("Product_Code")
  SET @lookup = Lookup('myDE', 'PRODUCT_CODE', 'PRODUCT_CODE', @ProductCode)

  IF NOT EMPTY(@lookup) THEN
]%%
1
  • So in the relational DE, the primary key is Product_Code and in the sendable DE the primary key is Email Address. Also, I'm editing my question and paste the code which I've written. It's working fine but except for the scenario, SendableDE > 2nd DE > 3rd DE, if value is present in 2nd DE, but not in 3rd DE it should not show Dynamic Content.
    – darkCloud
    Commented Apr 30, 2021 at 13:24

You must log in to answer this question.

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