Multi-Instance Management
Multiple Instances of a Declared Application
In some cases, an application declared in a SAP Intelligent RPA project may be launched on the desktop multiple times.
In this example, Desktop Agent detects two running instances of the same Web application (here: CRM) with two distinct InstanceIDs (CRM[13064] and CRM[9912]).
Desktop Agent receives technical events from the two running instances and can control both of them.
Multiple Instances of a Declared Page
In some cases, a page declared in an application can be detected several times in the same instance of the application. This can be due to an incorrect declaration of the page, causing two different pages to be detected as the same page. In this case, you must improve the recognition criteria of the page in order to target the right one.
This can also happen if the controlled application opens the same page twice. In this case, the problem is: how to make sure the right page instance is controlled?
Multi-Instance Management Using the Desktop SDK
Default Instance Management
-
Determine the application's InstanceID
-
If the last event received has a valid application InstanceID, this will be used (see the ev.appliInst property).
-
Else, if there are running instances of the application, the first InstanceID is used.
-
Else, you must start an instance of the application and wait until you receive a technical event from it (START event).
-
-
Determine the page's InstanceID
-
A valid application InstanceID has been determined.
-
If the last event received carries a valid page InstanceID, it is used (see ev.pageInst property).
-
Else, if there are running instances of the page, the first InstanceID is used.
-
Else, the control action will return an error.
-
-
For technical events, they are set by the Desktop Agent connector.
-
For functional events, the application InstanceID can be set by the sender of the event via the notify method.
Examples:
Code executed on reception of a technical event
Code executed on reception of a functional event
Default instance management saves you from having to provide InstanceIDs when controlling actions. But that is not enough if you have to manage multiple instances of an application.
Controlling a Specific Instance of an Application
-
A Web application controlled by Desktop Agent in the background.
-
The same Web application used by the user in the foreground.
How can you be sure that the dedicated running instance is controlled, and not the one launched by the user? You can do this by setting the default instance on an application using the ctx.application.setDefaultInst method:
-
You will not receive any technical events from the other instances.
-
Other instances will not be taken into account by default instance management.
-
You cannot control other instances using the syntax <MyAppli[otherInstance]>.
Controlling Multiple Instances of an Application Simultaneously
Suppose that you control several instances of the same Application simultaneously. How can you be sure that the technical events triggered by different instances don't interfere?
You can do this by setting a default application instance for a running scenario using the sc.setDefaultInst method:
Once the default application instance is set for a running scenario:
-
Handlers set in the steps of the scenario will not be triggered by technical events from the other instances.
-
Other instances will not be considered in Default instance management inside the steps of the scenario.
-
You can still control other instances using the syntaxMyAppli[otherInstance]