Invoke Code with Python code in it

Hello, I have a big problem with Invoke Code, I run the process many times and sometimes the Invoke Code activity is not executed, but goes straight to the For Each container, and since the array used in For Each is declared in the Invoke Code activity, an error is raised, however, I found a way to stop these errors, I set the Delay activity before the Invoke Code activity, how can this be explained? In Invoke Code I use Python and attached the code in the screenshot

Are you sure this is not executing at all? If the delay helps it looks more like a race condition somewhere.
Can you try adding a print statement at the beginning of the InvokeCode? That way it would be clear that it really doesn’t get there.

That aside, for a simple file read (assuming this isn’t just a minimal repro) you don’t need python, and can use build in .Net functionality.

// make sure that variable listWithEmails of type Array(Of String) exists
// then in an Assign activity
listWithEmails = IO.File.ReadAllText(recipientsFile, Text.Encoding.UTF8).Split({","c}).ToArray()
// ^ code not tested, but you should get the idea
1 Like

Yes, I am sure. I added print at the beginning of this block and sometimes the message didn’t come out, so that’s not the problem

But I like the idea of code in assign, thank you!

I have another example, I removed the file reading from the code, I just set the value in the code and print before it, but it just skips this step


try adding a writeline ABOVE the if statement checking recipientsFile.
something like
"Before If " & (recipientsFile isnot nothing).ToString()
so you can check if you are even executing the if

I tried it already, everything works fine, its something about Python, because if I write the code on C#, everything work perfectly fine

Something wrong with the Python, pls check and fix it, I think something is wrong with async, because it happens mostly when I reboot server and run this process many times in a row.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.