I am trying to display firstname
and lastname
of patient under one doctor if field Date_FX_Plan_Approved__c
is null
. First I'm trying to pass subscriber key (Id
) to @Idd
which is in Acc
DE, then do lookup on Account_Salesforce
DE to the fetch firstname
, lastname
. There can be multiple patients under one doctor, so my objective is to retrieve patients full name where there Date_FX_Plan_Approved__c
is null/
The error I am receiving is
The subscriber preview failed to generate. Review the details, correct all issues, and try again. An IF statement is not closed with the required ENDIF statement. ClientID: 514001327 JobID: 0 EmailID: 0 Index: 2984 Statement: if @rowCount > 0 then for @i = 1 to @rowCount do var @firstName, @emailAddress, @rank @Date_FX_Plan_Approved__cc set @row = row(@rows, @i) /* get row based on counter */ set @rank = field(@row,"Id") set @firstName = field(@row,"FirstName") set @emailAddress = field(@row,"LastName") set @Date_FX"
The code:
%%[
var @rows, @row, @rowCount, @numRowsToReturn, @region, @i , @Id, @Date_FX_Plan_Approved__c , @Idd , @firstName, @lastName, @rank , @Date_FX_Plan_Approved__cc
set @Id = AttributeValue("Doctor__c")
set @Idd = AttributeValue("Id")
set @numRowsToReturn = 0 /* 0 means all, max 2000 */
set @rows = LookupOrderedRows("Acc", @numRowsToReturn, "Id desc, Name asc", "Id", @Idd)
set @Date_FX_Plan_Approved__c = Lookup("Account_Salesforce", "Date_FX_Plan_Approved__c", "Id" , @Idd)
set @rowCount = rowcount(@rows)
for @i = 1 to @rowCount do
set @row = row(@rows, @i) /* get row based on counter */
set @rank = field(@row,"Id")
set @firstName = field(@row,"FirstName")
set @lastName = field(@row,"LastName")
]%%
%%[ next @i ]%%
%%[ else ]%%
No rows found
%%[ endif ]%%
IF EMPTY(@Date_FX_Plan_Approved__cc) THEN
SET @ln = @lastName
SET @fn = @firstName
ELSE
SET @ln = @lastName
SET @fn = @firstname
ENDIF
]%%
%%=v(@ln)=%%, %%=v(@fn)=%%