We are sending emails via salesforce markering cloud in response to actions on our website. The idea is that we store data related to the subject of the email first via their api. When we have a confirmation that everything is stored we add data to a transactional email queue. The problem is that when this email is triggering we are attempting to use the data previously stored in the markering cloud. But we run into an issue were sometimes the data isn't available yet - maybe their internal transfers between different data stores is a bit slower then the triggering.
set @orderItemsLookup = LookupOrderedRows("Order Lines", @numRowsToReturn, "SKU, Name, Quantity, Price, Image, BodyFit, Collar, Color, Size, Pattern, Fabric", "OrderID", OrderID) set @itemsRowCount = rowcount(@orderItemsLookup) ... %%[ if @itemsRowCount > 0 then for @a = 1 to @itemsRowCount do var @DE_Image <-- line giving exception ...
This line is attempting to check that if we have data, render that data, otherwise ignore it.
We however get this error from the api.
The initial end count value for the for loop could not be cast to an integer.
And the code they are referencing in the email:
for @a = 1 to @itemsRowCount do var @DE_Image
However, Should our if catch this error? Or could the if statement be true in any other case?
UPDATE I realise that we have a weakness in the script stretching over several blocks. There is a possibility that the @itemsRowCount might not be initialised at all - but in that case - why does the if statement evaluate to true?