Given that I have already declared my variables... I am trying to set some values to those variables, based on whether a row of data already exists or not...
VAR @brandID, @Content, @Header, @subscriberkey, @cottage1ID, @cottage2ID, @cottage1Name, @cottage2Name, @viewDate1, @viewedProperties, @viewedPropertyRow, @viewedPropertiesRows, @viewPropertyCount, @viewDate2, @currentDate, @dayDiff, @bookingRows, @AllBookingRow1, @bookingRowCount, @AllBookingRowCount1, @viewedPropertyID, @AllBookingRow2, @AllBookingRowCount2, @viewedOtherPropertiesRows, @viewedOtherPropertyRow, @viewedOtherProperties, @viewOtherPropertyCount
Could someone explain to me, why this works:
SET @viewedPropertiesRows = LookupRows("Viewed Properties","Subscriber Key", @subscriberkey, "brandID", @brandID)
SET @viewPropertyCount = rowcount(@viewedPropertiesRows)
IF @viewPropertyCount > 0 THEN
SET @viewedPropertyRow = row(@viewedPropertiesRows, 1)
SET @cottage1Name = field(@viewedPropertyRow,"cottage1Name")
SET @cottage2Name = field(@viewedPropertyRow,"cottage2Name")
SET @cottage1ID = field(@viewedPropertyRow,"cottage1PropertyID")
SET @cottage2ID = field(@viewedPropertyRow,"cottage2PropertyID")
SET @viewDate1 = FormatDate(field(@viewedPropertyRow,"View1_happenedAt"), 'yyyy-MM-DD')
SET @dayDiff = DateDiff(@viewDate1,@currentDate,"D")
ENDIF
IF(EMPTY(@viewPropertyCount) OR @viewPropertyCount == 0) THEN
SET @viewedOtherPropertiesRows = LookupRows("Viewed Properties","Subscriber Key", @subscriberkey, "brandID", 1)
SET @viewOtherPropertyCount = rowcount(@viewedOtherPropertiesRows)
IF @viewOtherPropertyCount > 0 THEN
SET @viewedOtherPropertyRow = row(@viewedOtherPropertiesRows, 1)
SET @cottage1NameOther = field(@viewedOtherPropertyRow,"cottage1Name")
SET @cottage2NameOther = field(@viewedOtherPropertyRow,"cottage2Name")
SET @cottage1IDOther = field(@viewedOtherPropertyRow,"cottage1PropertyID")
SET @cottage2IDOther = field(@viewedOtherPropertyRow,"cottage2PropertyID")
SET @viewDate1Other = FormatDate(field(@viewedOtherPropertyRow,"View1_happenedAt"), 'yyyy-MM-DD')
SET @dayDiffOther = DateDiff(@viewDate1Other,@currentDate,"D")
ENDIF
ENDIF
but this doesn't:
SET @viewedPropertiesRows = LookupRows("Viewed Properties","Subscriber Key", @subscriberkey, "brandID", @brandID)
SET @viewPropertyCount = rowcount(@viewedPropertiesRows)
IF @viewPropertyCount > 0 THEN
SET @viewedPropertyRow = row(@viewedPropertiesRows, 1)
SET @cottage1Name = field(@viewedPropertyRow,"cottage1Name")
SET @cottage2Name = field(@viewedPropertyRow,"cottage2Name")
SET @cottage1ID = field(@viewedPropertyRow,"cottage1PropertyID")
SET @cottage2ID = field(@viewedPropertyRow,"cottage2PropertyID")
SET @viewDate1 = FormatDate(field(@viewedPropertyRow,"View1_happenedAt"), 'yyyy-MM-DD')
SET @dayDiff = DateDiff(@viewDate1,@currentDate,"D")
ELSEIF(EMPTY(@viewPropertyCount) OR @viewPropertyCount == 0) THEN
SET @viewedOtherPropertiesRows = LookupRows("Viewed Properties","Subscriber Key", @subscriberkey, "brandID", 1)
SET @viewPropertyCount = rowcount(@viewedPropertiesRows)
IF @viewPropertyCount > 0 THEN
SET @viewedPropertyRow = row(@viewedPropertiesRows, 1)
SET @cottage1Name = field(@viewedPropertyRow,"cottage1Name")
SET @cottage2Name = field(@viewedPropertyRow,"cottage2Name")
SET @cottage1ID = field(@viewedPropertyRow,"cottage1PropertyID")
SET @cottage2ID = field(@viewedPropertyRow,"cottage2PropertyID")
SET @viewDate1 = FormatDate(field(@viewedPropertyRow,"View1_happenedAt"), 'yyyy-MM-DD')
SET @dayDiff = DateDiff(@viewDate1,@currentDate,"D")
ENDIF
ENDIF
I feel like I am going crazy, but there must be a rational reason! many thanks