But after using below expression, ienFilteredQueueItems.Count throws error. Only difference is now I am comparing field value with a variable strCompareValue
Error: An ActivityContext can only be accessed within the scope of the function it was passed into.
Object name: ‘System.Activities.CodeActivityContext’.
Could you please help, what’s going on here? I can not share any workflow. But steps to reproduce are as below:
Use Get queue items to get few queue items
Filter with above expressions for picking few queue items which have some specific field value in it
Log the count of final filtered queue item
Log activity throws error when I am comparing the queue items field with a string variable instead of a direct string value.
@Anil_G Thanks for replying.
I actually do not need the count. It was just to state that ienFilteredQueueItems is not getting any results on using the second expression. Even if just use the For each loop on ienFilteredQueueItems , logging of item.Reference is also throwing the same error.
Basically for loop or those needs array and no IEnum I feel…Because I saw this error in a similar situation and it got resolved by adding toarray or tolist
So try that in your for loop as well try casting it to toarray and check then if you are able to get the reference
I’m still working on this, this seems a bug for now because when you pass string value expression returns IEnumerable of QueueItem and when using variable then it throws an exception that’s why .Count is not working.
Use in arguments: str variable to filter and IEnumerable of type QueueItem to filter on.
Use out argument: IEnumerable of type QueueItem to store filtered queue Items.
Paste code: out_queue = in_queue.Where(Function(x) x.SpecificContent(“yourFieldName”).ToString.Contains(in_str))
typically we do see this, when within the LINQ processing something is failling. (will also happen, when executed within an invoke code activity).
As we do have an access to a Dictionary Key within the Specific Content, you can evaluate if all items do have the key. Use immediate panel and the following Statement:
Check 1: we check that it is not null
ienProcessedQueueItems
Check 2: all items do not have the key
ienProcessedQueueItems.Where(Function (x) Not x.SpecificContent.ContainsKey("Field1")).ToArray
Based on the results from this checks we can decided next further analysis when it is still needed