Getting Error with "For Each UI Element Activity"

Hi Team,

I have created a process for Invoice Processing for a web-based application using “For Each UI Element Activity”. In the application when any invoice is processed it gets stored in the different bucket and automatically gets removed from the current bucket. I have created an automation for processing the invoice, but it is able to process only single invoice and after that it reflects the below mentioned error as the UI Element is constantly keep on changing.

Request to please assist on this issue.

Thank you in advance for the support.

Below is the snapshot for the reference:

Below is the error log for the reference:

24.4.0-beta.16568+Branch.release-v24.4.0.Sha.2580fa6cf8d62c2ce32ffb80535a02af198eb1da.2580fa6cf8d62c2ce32ffb80535a02af198eb1da

Source: For Each UI Element

Message: Source data was modified, for each operation can not continue.
This is likely due to changes in the target application while the For Each UI Element activity executes.

Exception Type: UiPath.UIAutomationNext.Exceptions.SourceDataModifiedException

UiPath.UIAutomationNext.Exceptions.SourceDataModifiedException: Source data was modified, for each operation can not continue.
This is likely due to changes in the target application while the For Each UI Element activity executes. at UiPath.UIAutomationNext.Activities.Helpers.UiNodeInfoEnumerator.MoveNext()
at UiPath.Shared.Activities.Business.ForEachEnumeratorExtensions.IterateAndReturnIfActionExecuted[T](Variable1 enumeratorVariable, NativeActivityContext context, ActivityInstance completedInstance, Boolean exitLoop, Action1 doAction, Action1 completedAction, Action1 exitAction)
at UiPath.Shared.Activities.Business.ForEachEnumeratorExtensions.Iterate[T](Variable1 enumeratorVariable, NativeActivityContext context, ActivityInstance completedInstance, Boolean exitLoop, Action1 doAction, Action1 completedAction, Action1 exitAction)
at UiPath.UIAutomationNext.Activities.NForEachUiElement.ExecuteForEach(NativeActivityContext context, ActivityInstance completedInstance)
at System.Activities.Runtime.ActivityCompletionCallbackWrapper.Invoke(NativeActivityContext context, ActivityInstance completedInstance)
at System.Activities.Runtime.CompletionCallbackWrapper.CompletionWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
— End of stack trace from previous location —
at UiPath.UIAutomationNext.Activities.NApplicationCard.OnFault(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

@anupam.dubey

For your case instead of for each ui element you need to use a do while loop with check app state …in the check app state indicste the first invoice click you need to perform and make sure you dont have any innertext or anything in selector…try havingn tag and class and have idx as 1 or row as 1 …as the invoices are processed every new invoice will have same tag and class and idx…so it would always click on first if availabe else end the loop…in the condition you can provide the output of check app state so that once the element is not found the loop would end

Hope this helps

Final flow

Do while with conditin as boolean variable of check app state
Inside loop check app state with first invoice selector
On found side perform Your clicks
On not found side do nothing

Cheers