Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 

I am writing this blog post to give a feedback and share my experience on SAP IRPA V2 and solutions for the challenges I got on my projects.
On this blog post, I share with you the technical steps to create an attended bot. For my use case, the bot needs to start the web site and wait on the user to login, this is very challenging because you can't use the wait function.

I suggest you this very simple solution, you must use custom script and write a java script code that I will explain.

Below is a screenshot to understand the case:


Workflow screenshot


Just to explain the flow, the bot will check if the application exists, if exist it close it to avoid that the bot get confused and restart it else only restart it, then we have two cases:

  1. Not connected: will get the connection page.

  2. Already connected: we just go forward.

In this blog post, we are interested in the case the user is not connected so the bot will wait on the user to login.


Part 1: How to wait on user action

Let us now get deeper and see the code in the custom script.

Wait on user to login

How it works:

  • Declare a Boolean variable with a scope for all the script

  • Add a call back function for the unload event so the bot will be listening on this event.

  • Add a while loop so the bot stack on this step

The bot will loop until the user enter his credentials and click on the connection button, at this time, the unload events will be triggered and the call back function will be executed. This function will set the Boolean variable to false as consequence we will break the loop.


Part 2: How to return data entered by the user

In case you need to return some data you read from the page, you can do like this


How to return a value



Side effects:

In my case, the bot works fine but I noticed that for the second execution it works differently, I opened a SAP note regarding this, meanwhile I suggest you this solution as workaround. I use VB script that kill the agent to be restarted so he will have a new context.

Kill RPA process


To sum up:

In this blog post we saw how to create attended bots.

  • In the first part, we saw the java script that enable us to let the bot wait for the user action.

  • Then how we can return data entered by the user


Hope this blog post helped you to solve your challenge. I will be very happy to read your comments or feedback either for improving my suggestion or introduce other challenging aspects.


Find bellow the scripts:

Custom script to wait on page load:

var loop = true;

loop = false;

irpa_core.core.log('', irpa_core.enums.logType.Info,'pExportSearchInvoices');

irpa_core.core.log('pConnexion looping ' + loop, irpa_core.enums.logType.Info,'looping');
await irpa_core.core.waitTime();

irpa_core.core.log('pConnexion loop end', irpa_core.enums.logType.Info,'afterLoop');


Kill RPA Process:

function formatEscapteCaracters(f) {
return f.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '');
irpa_core.core.log('custom script Kill RPA Process', irpa_core.enums.logType.Info, 'KillRpaProcess');
try {

var VBScode = formatEscapteCaracters(function () {/*!
'Sub KillRpaProcess()
For Each Process In GetObject("winmgmts:").ExecQuery("Select Name from Win32_Process Where Name = 'SAPIntelligentRPAStudioAgent.exe'")
For Each Process In GetObject("winmgmts:").ExecQuery("Select Name from Win32_Process Where Name = 'CtxtRun.exe'")
'End Sub
var path = '';
if(await irpa_core.fs.exist('C:\\Users')){
irpa_core.core.log('C:\\Users', irpa_core.enums.logType.Info, 'Custom script');
path = 'C:\\Users\\' + irpa_core.options.userName + '\\Downloads';
await irpa_core.fs.file.write(path + '\\killRPA.vbs', VBScode);
irpa_core.core.log('custom script Kill RPA Process End', irpa_core.enums.logType.Info, 'KillRpaProcess');
irpa_core.core.shellexec(path + '\\killRPA.vbs');
} catch (error) {
irpa_core.core.log('KillRpaProcess Exception occured:' + error, irpa_core.enums.logType.Error, 'KillRpaProcess');





1 Comment
Labels in this area