Question
Achmea
NL
Last activity: 16 Dec 2021 13:53 EST
How to properly use functions in Pega Robotics
Hi Pega,
I have made a few functions for a certain use case (further: "use case 1"). These functions are tested properly and work well.
Later I imported ("add existing items...") a couple of these functions to use case 2. These functions also work well in this second use case. But if these use cases were to come together in one solution for some reason, this way of working will cause a few errors, because the automation ID's will be identical.
What is a proper way to work with functions? And what would be a good way to handle the situation above (manually adjust ID's in the .OS)?
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
A solution should consist of multiple projects. If you keep your use cases in separate projects, then the IDs matching wouldn't be an issue. If you do have items in the same project that you want to make a copy of though, then the best way is to change the ID. I usually open it up in a text editor and replace it with a new ID. I generally change the last five characters to random numbers (or letters A-F).
Updated: 28 Oct 2020 12:44 EDT
Achmea
NL
Would it be a good option to make one solution with a collection of tested functions and just import this solution where it's needed?
Pegasystems Inc.
US
You could create a project that you use that has a collection of things you'd use in your other projects. The thing you "import" (it is really a reference), is the project and not the solution.
Achmea
NL
I mixed things up in my last post, I indeed meant projects.
If the functions were to be in a dedicated project, it would be easier to manage the functions. For example: if for some reason a function needs to be adjusted it can easily be done by updating the dedicated project. Whereas if you would have made copies of those functions (and changed the ID's), you would have to track down all of the copies and make the adjustments in the separate copies.
Pegasystems Inc.
US
This is the correct way to do this.
-
Robin Tijs
Updated: 18 Jun 2021 11:09 EDT
Achmea
NL
@jeffbadger I added a solution to the attachment of this reply.
In this solution there are 5 functions we are currently using. We provided the functions with comments and examples. Any feedback or improvements are very welcome!
When you run the solution the Robot Inspector will appear. We use the robot inspector as a quick way of testing our functions.
Now days we don't import a project with all of the generic functions anymore. We collected all our functions in a central directory. If we ever need a functions, we take the following course of action: (1) click "Add project items", (2) click "Existing item", (3) click "Browse" and pick the desired function from the directory, (4) click the checkbox "Generate new ID", (5) click "Add". This way a new copy is made of the function and a new ID is generated. Even if two of the same functions were to ever come in the same solution, it wouldn't cause problems (because of the different ID's).
Pegasystems Inc.
US
@RobinT51 Hi Robin. There is a new preview of our next release - Pega Robot Studio v21 - now available on Digital Download. Please feel free to try it. I thought I would share with you how some of your functions would be done in v21.
F_AddLeadingZeros - PadLeft and PadRight have been expanded in v21 to support supplying the padding char. This can be done directly on the variable like this:
F_DeleteLeadingZeros - Since the introduction of new variables in 19.1.54 you can test to see if a string contains a number and remove its leading zeros like this:
I like that you have packaged the prompting for credentials with your standard GetCredentials. We will explore that as a possible addition to GetCredentials. In the meantime, I would recommend adding a bool parameter named promptForNew to your ClearCredentials to determine if GetCredentials should be called after the credential is cleared from within ClearCredentials.
Have you added anything to your function list since your previous post?
Thanks,
Jeff
Updated: 16 Dec 2021 4:46 EST
Achmea
NL
@jeffbadger Hi Jeff, thank you for your response.
Pega Robot Studio v21 looks promising. I’d be happy to test it in advance. Thank you for improving our generic functions. It’s nice to see there are better OTB possibilities to do the same with less effort and complexity! Since my last post, we added three generic automations:
P_CheckDownloads
For several business cases, it's important to download a file in a (web)application. After this file is downloaded (which takes a few seconds) we want to perform the next action with this file (like editing it or moving it to another location). This requires us to make sure the download is finished, and for the relevant methods we need a FileName/FilePath.
This automation is created for this purpose. It checks the download directory for a certain file with the timestamp of today. If it finds the file, it will return the FileName and FilePath of this file. If it finds more than one file, it will return the most recent file (based on the last write time).
P_SendKeys
In our RDA projects we sometimes had to use the “Sendkeys” method (there was no other way). We noticed that if users would type something at exactly the same moment as the robot would use the SendKeys method, the typed text (by the user) would also populate the text box the robot was interacting with.
@jeffbadger Hi Jeff, thank you for your response.
Pega Robot Studio v21 looks promising. I’d be happy to test it in advance. Thank you for improving our generic functions. It’s nice to see there are better OTB possibilities to do the same with less effort and complexity! Since my last post, we added three generic automations:
P_CheckDownloads
For several business cases, it's important to download a file in a (web)application. After this file is downloaded (which takes a few seconds) we want to perform the next action with this file (like editing it or moving it to another location). This requires us to make sure the download is finished, and for the relevant methods we need a FileName/FilePath.
This automation is created for this purpose. It checks the download directory for a certain file with the timestamp of today. If it finds the file, it will return the FileName and FilePath of this file. If it finds more than one file, it will return the most recent file (based on the last write time).
P_SendKeys
In our RDA projects we sometimes had to use the “Sendkeys” method (there was no other way). We noticed that if users would type something at exactly the same moment as the robot would use the SendKeys method, the typed text (by the user) would also populate the text box the robot was interacting with.
This automation sets the whole text of a text box except for the last character. The last character is send with the SendKeys method. This way we reduce the chance of an user interrupting a RDA solution.
P_GetClones
In some projects we use the “UseKeys” option, and we want to get a collection of clones. The object, being the clone, needs to be fully loaded so all clones are present in the clone collection. We noticed that if we would use a WaitForCreate on the clone, in some cases not all clones were loaded. This would result in an incomplete collection of clones.
This automation counts all the clones and checks if the collection got bigger after a short pause. If the collection did get bigger, it pauses again and again, until the amount of clones doesn’t increment any further. This automation then returns the complete clone collection.
F_DeleteLeadingZeros
I also added the new version of “F_DeleteLeadingsZeros” to this new version of the Project Functions_2. I tested it and it works very well.
There’s also something I wish to have a generic automation for: storing information other than credentials. In some of our solutions, the users uses an input worksheet to work with the robot. We don’t want to hard reference the location of this input worksheet. So we make this location variable by letting the user pick this file (OpenFileDialog). If the user closes the robots and starts it again the next day, the user would have to pick the location again. What would be a proper way to save this path for the next run? In my current situation, I saved the chosen Filepath in de ASO.db because it was quick and easy (even though it’s not meant for it). What would be a better way of doing this?
You can find all these generic automations in the attachment. Feedback and/or improvemens are very welcome.
Updated: 16 Dec 2021 13:53 EST
Pegasystems Inc.
US
@RobinT51 Great ideas Robin. You are not alone with these challenges.
The ability to have greater control over downloads in Chrome and Edge is in development. You will be able to know when downloads have started, when they have completed, when they have failed from blocks on your automations.
Sendkeys has always been problematic when you have users present. They can change the focus or the automation rips focus out from under the user. I will pass on your solution to the team working in that area - I have used that in the past myself on occasion.
Waiting on clones is a common problem. It is important to wait on the parent control of the cloned item. In most cases, it will only match after all of the clones are matched. When that is not the case, waiting on the collection size to stop changing is the current best practice. We have had requests for additional ways to wait on various actions to complete and will be looking at options to make that better in v21.
As far as a place to store information - we currently don't have a better way to do it than the CredentialStore or ASO.db. I recommend CredentialStore as it is easier to hide the information from the user.
As for v21, please download the Preview and share your feedback. We are working to be sure that v21 is easier to use, speeds development and provides a wealth of additional OTB functions.
-
Robin Tijs