Hi
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.
First, I would like to thank Baptiste from SAP who helped me to find this solution.
You surely noticed that when you run an automation in both cases success and fail there is no log on factory regarding this job.
On this blog post, I share with you the technical steps how to upload logs to factory.
Introduction
For Demo purpose, I created the ‘main workflow’, with 3 automations
libLogs: The automation where we manage the log, it exports an object of type any (called helper)
logPart1: automation take as input parameter the ‘helper’ and push some logs
logPart2: automation take as input parameter the ‘helper’ and push different logs
The most important is that the ‘main workflow’ automation has an output parameter that return the ‘helper’ object.
The idea is demonstrate how to get the entire log through the job execution.
Technical Steps:
Let us get deeper and see each automation content
- libLogs
We declared an array ‘’Log” and two functions to manipulate this array:
addLog: to push logs in the array with some formatting like adding the step, the event or the function and the detail.
returnLogs: return the log variable
var logs = [];
function addLog(ipsScenario, ipsStep, ipsEvent, ipsFunction, ipsDetails){
var log = '[' + ipsScenario + '][STEP]' + ipsStep;
if(ipsEvent)
log = log + ' [EVENT]' + ipsEvent;
if(ipsFunction)
log = log + ' [FNCT]' + ipsFunction;
log = new Date().toString() + log + ' [Details]' + ipsDetails;
logs.push(log);
}
function returnLogs (){
return logs;
}
return {
addLog : addLog,
returnLogs: returnLogs
};
- libLogPart1 / libLogPart2
In this automation, we are using the “Repeat” activity and on the custom script we call the function log on the input parameter helper.
To differentiate the logs we are logging the index.
The only difference between libLogPart1 & libLogPart2 is the “Repeat” activity starting and ending value.
libLogPart1 : from 1 to 10
libLogPart2 : from 20 to 30
- Returning the “helper” object
Test:
Important:
Note that the fact we are using the sharing the ‘helper’ object through the automation, it is like a pattern that makes the log variable a shared resource that we can access only through these two functions
If for each automation you include the ‘libLogs’: each time you’ll get a new instance of the variable ‘log’, hence you will get only the last automation log.
Note that if you log too much, this mechanism may lead your bot to fail because you will push too much data on the array and you will overload the heap (stack overflow)
To sum up:
In this blog post, we saw step by step how we can upload the logs to the factory
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.