I’m looping over an array of strings, to find certain values within the strings.
In each iteration of the for each loop
I’m passing that string/line into an invoke activity
with an if inside and in that if an assign to an OUT variable.
Example the data I need is on line 5, 7 and 9
when the data from line 5 is extracted and the loop goes to line 6 I lose the value of the variable
same of 7 and 9.
The scope of the variable is set on the highest level. I’ve stepped through the entire array manually and it happens always when exiting the loop.
Would you be so kind as to provide us with an example, or the sample data itself?
I don’t think its necessary to use an Invoke Activity to perform this, I can think of something once I see the data.
I’ve stepped with debug through the entire document, the value only gets put into the variable when the if condition is true, so no that is not the case.
The values are lost when a new iteration of the for each starts.
That is correct that it is not necessary to use an invoke activity for this. I’ve moved the logic from in the invoke activity into the for each and it works as it should.
But I would still like to know how or why the values are lost with an invoke activity.
Without having a Visual on the Workflow Developed, It would be difficult for us to Provide you with the Exact reason, But if you are using an Invoke Code Activity, then it might be due to the way the arguments are passed i.e direction of the Arguments, In/Out.
If you could provide us with more details we could confirm the case.
Then you have the variables scoped to the For/Each’s internal sequence. You said you scoped them to the highest level, but are you sure you don’t have duplicates?
I pass in a file as string
I split that string into an array of strings
then loop over that array of strings
i pass each line into an activity
which checks if some value occurs in that string
if so it assign a substring to an out argument
which gets auto assigned to a variable in the import arguments.
if not nothing happens and the loop continues
Here below some screen caps
i’ve commented the invoke activities as i move the logic into the for each.
I’ve double checked no duplicates in the variable names and indeed scoped to the highest level.
Without an invoke activity it all works, with it does not.
HI @Benjamin_Degryse ,
For all the lines you are calling invoke method and assign to the same variable. for 5th line we are getting output but for 6th record not getting the value since condition not satisfied and returns empty value and assigning to same variable so previous value will be lost.
I am not using invoke code.
I was using invoke activity.
Please check the reply of Arivu.
It’s because with an invoke activity, if no assign happens the activity returns an empty value
which gets assigned to the variable ands thus the value gets lost.
The solution is not using an invoke activity but just assign.