I'm using the following AMPscript to set variables and to allow fallback values if data isn't available for a Guardian.
%%[ SET @rows = LookupRows("Contact_Salesforce","Id", _subscriberkey) SET @row = row(@rows,1) SET @firstName = field(@row,"firstName") SET @He_She__c = field(@row,"He_She__c") SET @Guardian_First_Name__c = field(@row,"Guardian_First_Name__c") IF NOT EMPTY(@Guardian_First_Name__c) THEN ] %% Dear %%=v(@Guardian_First_Name__c)=%%, %%[ELSE]%% Hello,%% [ENDIF]%%
It works in 99% of cases, but I've just noticed that it triggers an error in 1% of cases when testing some new data.
I get this error:
Invalid index (parameter 2) passed to Row function. Index must be less than or equal to the row count. Index Value: 1 Row Count: 0 Function: row(@rows,1)
Can anyone shed any light on this? To my simple brain, this seems like an error that should happen in all cases, not a select few.