1

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?

  • Would you mind updating your question to include a full sample of the AMPScript from your email? – Adam Spriggs Mar 28 '18 at 15:41
  • If you could expand on how you define @itemsRowCount, that would be helpful as it appears to be the issue. – Gortonington Mar 28 '18 at 16:06
1

@Linus Andrén don not use like that var @DE_Image use like this set @DE_Image

for @a = 1 to @itemsRowCount do 
  set @DE_Image=""
    write your code here
 next @a
 endif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.