Jasper Miller
ServiceNow Employee
ServiceNow Employee

(Hands-on exercise. Required time: Approx. 1.5 hours).

 

In this article, I will take you through the steps required for executing a Robot from a Flow in App Engine and providing it with data from the platform. The instructions that I will provide, will take you all the way from building the app, designing the robot, importing it into your ServiceNow instance, managing required configurations, passing data and executing it from the platform. You can go through this example with no, or very limited, skills and experience with App Engine and ServiceNow RPA. The only pre-requisite is that you have a ServiceNow instance (e.g. a developer instance) with RPA hub installed and a (virtual) machine with RPA Desktop Design Studio installed.

 

Please note that the example used here has absolutely no business value or use-case and the objective is to provide a technical step-by-step walk through of the configurations. In real-world scenarios, use-cases are plentiful.

 

Let's get started...

 

1. Configuring the data model:

 

In App Engine Studio, I have initiated the creation of a new App called "AES2RPA". The screenshot below shows the App Home:

 

1. AES.png

 

What we will do now is create a datamodel consisting of just two fields, a text field and a number field. These fields will contain the data that we will send to the robot later.

Click on "Add" in the Data section to add a table to the solution. The following screen appears:

 

2. AES.png

 

Pick "Create a Table"...

 

3. AES.png

 

Here you can either create a data model from an existing Excel spreadsheet (of which there are myriads in most organizations), extend an existing table (such as Task, which is the most commonly extended table in ServiceNow) or create a new table from scratch. We will do the latter:

 

4. AES.png

 

You can call the table AES2RPAValues (or what you like) and add auto-numbering to keep records unique. On the next screen, you can configure access permissions to the table and data for admins (fulfillers) and users (requesters).

 

5. AES.png

 

Now, the table has been created, but since we didn't configure our data fields yet, we opt to "Edit table" on the next screen:

 

6. AES.png

 

Now we enter the table designer where the structure of the table is displayed. As you can see, the table already has a few standard-, required fields to match the common data model of ServiceNow.

 

8. AES.png

 

We will now add two new fields to the table. Click "Add new field" and configure as shown below:

 

9. AES.png

 

Please note that the "Display" toggle is switched on for the two new fields. This will ensure that the fields are displayed and accessible by default in ServiceNow's standard interfaces for record creation. When you click "Save" and close the table designer, you are taken back to the App Home where you can now see the new components, one table and one Experience i.e. the standard representation of the table as a form for data entry. For now, this concludes our configurations in App Engine Studio and we move to our (virtual) machine where RPA Desktop Design Studio is installed. 

 

If you would like to know more about installing the RPA Desktop Design Studio or other RPA applications, please use this link: Robotic Process Automation (RPA) Hub 

 

2. Building the robot process:

 

When launching the RPA Desktop Design Studio, you will see the welcome screen:

 

11. RPA.png

 

From the interface, select "Create new automation project"->"Unattended Automation". To learn more about unattended and attended robots, please use this link: Robotic Process Automation (RPA) Hub 

 

Configure the New Unattended Project screen with a project name and description as seen below:

 

12. RPA.png

 

Once you enter the designer interface of RPA Desktop Design Studio, ensure that the studio is connected to your ServiceNow instance by clicking "Connection Manager" in the center of the tool pane, adding your ServiceNow instance credentials and clicking Log in.

 

13. RPA.png

 

Upon successful pairing, you will notice the URL of your instance and a green dot in the bottom of the screen.

 

The robotic process, that we will build now, will fetch data from your ServiceNow instance and simply write it to Windows Notepad. In order to automate Windows desktop applications, we need to add a Windows plugin. Right-click on Plugins in the Project Explorer and select "Add Plugin":

 

14. RPA.png

 

From the list, select "Windows" and click "ADD". When "ADD" shows a green tick, click "OK" to close the dialog:

 

15. RPA.png

 

You can now confirm that the Plugin is listed in the Project Explorer and in the list of Connectors in the toolbox on the Left:

 

16. RPA.png

 

The first thing this process will do when executed, is to pull an AES2RPAValues entry from a Queue in your ServiceNow instance. To do this, we will make use of the Queue component, located in the RPA Hub section of the toolbox. Drag the Queue component to your Global Objects in the Project Explorer:

 

17. RPA.png

 

Double-click the Queue object in the Project Explorer to make use of it. When doing so, two things happen: the Properties window displays the properties of the component, such as name and which queue (in RPA Hub) to pull data from, and the Toolbox changes to an Object Explorer which lists the available actions (methods) that are available for this object type.

Change the QueueName in the Properties pane to AESRPAQueue. This queue has not yet been created but we will do so later.

Now drag the Method called "PickWorkItem" from the Object Explorer onto the stage, next to the start step:

 

18. RPA.png

 

Now connect the Start step with the Queue/PickWorkItem step by dragging a connector from the gray port on Start to the gray port on Queue.

The RPA Hub queue will pass data to the Robot as JSON. Therefore we need to deserialize it to an object before using the contents in the process. To do so, find the Deserialize Object action in your toolbox under Utilities->JSON and drag it onto the stage after the Queue step.

 

19. RPA.png

 

Connect the yellow Data output port on the Queue step (RequestContent) to the Data input port (JSON) on the JSON step as shown above to pass the data from one step to the next. As you have now learned, the gray ports on the steps determine the execution flow of the process and the yellow ports determine the data flow within the process.

Now that the JSON data has been deserialized, we can pull the properties from the object and use them in the subsequent process steps. To get hold of the properties, drag the "GetProperties" action from the JSON section in the toolbox onto the stage:

 

20. RPA.png

 

Now click the gear icon on top of the GetProperties step to configure the JSON path to object properties and configure as seen below:

 

21. RPA.png

 

Connect the JSON steps' execution ports and data ports as shown above.

At this stage in the process, we now have the required data ready to go, so let's start the Notepad application. From the toolbox, in the section "General", drag the Start App action onto the stage and connect it to the JSON steps from earlier.

 

22. RPA.png

 

To configure the Start App step, double-click the "Path" setting in the step and enter/paste the path to the executable. For most Windows environments, the path is %WINDIR%\System32\Notepad.exe equivalent to C:\Windows\System32\Notepad.exe.

Now it's time to map the components in the Notepad interface that we want to work with in our process. To work with a Windows desktop application, we will make use of the Windows plugin that we added earlier and the Windows Connector that it provides. In the Connectors section of the toolbox, locate the Windows Connector and drag it to Global Objects in the Project Explorer as seen below. Double-click (or right-click) the connector to rename it to "Notepad" either in the Properties window or through the context menu:

 

23. RPA.png

 

Now, to register the user interface components with the RPA project, we literally have to "point them out" to the RPA Desktop Design Studio. In order to do so, manually open the Notepad application from the start menu:

 

24. RPA.png

 

With the Notepad window in the background, right-click the "Notepad" Windows Connector and select "Configure":

 

25. RPA.png

 

The Windows Connector configuration window opens. In this component, you can define application windows and components therein such as text boxes, buttons or other controls that you wish to use in your automation project. From the Available Windows drop-down, select Notepad and click "Add Window":

 

26. RPA.png

 

The Notepad window has now been added to the WINDOWS pane. Right-click it and select Focus to bring the window forward:

 

27. RPA.png

 

Now right-click one more time and select "Add Element". We are going to add the large text container (called an edit) to our process:

 

28. RPA.png

 

The next part may take a little getting-used-to. In the current state of the the RPA Desktop Design Studio, the mouse cursor drags a small configuration pane around on the screen and registers which components you are hovering the mouse over. Move the mouse over the large edit in the Notepad window:

 

29. RPA.png

 

Now hold down the CTRL button on your keyboard to make the configuration pane stop moving. Enter a name for the component as seen below and click the green plus sign:

 

30. RPA.png

 

In the Windows Connector configuration window, you will now notice the edit_notepad control nested in the Notepad Window. For the purpose of this exercise, no further configuration is required. Click OK to close the connector configuration.

 

31. RPA.png

 

Find the edit_notepad object in the Project Explorer and double-click it to bring up the list of available methods for this type of object (in the Toolbox pane). Drag the "SetText" method onto the stage:

 

32. RPA.png

 

Before we can set the text in Notepad, we need to format or concatenate a text string from our JSON variables. To do that, we need an action called "Format Text". Find it in the General section of the toolbox and drag it onto the stage:

 

33. RPA.png

 

We need two placeholders for the variable data (text value and number value). To add these to the step, click the green plus sign twice:

 

34. RPA.png

 

Connect the (yellow) data output ports on the JSON GetProperties step to the data input ports on the Format Text step as seen below:

 

35. RPA.png

 

Now click the gear icon on top of the Format Text step to configure. I want to write "TextValue = <the text value> ... NumberValue = <the number value>" in Notepad, so the configuration looks like this:

 

36. RPA.png

 

Click OK to close the Format Text configuration window and connect the last ports, so that your completed process looks exactly like the screenshot below:

 

37. RPA.png

 

We are done building the RPA process and now we need to publish it to our ServiceNow instance. Save the project and click the RPA Hub button on the tool pane:

 

38. RPA.png

 

Configure the "Publish Project" window as seen below and click Publish:

 

39. RPA.png

 

3. Configuring RPA Hub:

 

Back in the ServiceNow instance, specifically the RPA Hub, we now have some configuration to do. Firstly, we need to make sure that we have an unattended robot running on a Windows machine to execute the robot. You will most likely, like me, use the same machine where we have built the robot.

In RPA Hub, go to Administration->Robots and select "New":

Configure the Create New Robot screen as seen below. Fill in a robot name, the name of the machine where the robot will reside and the robot type (unattended):

 

45. RPA Hub.png

 

Make sure that the Unattended Robot application is running on the target machine and verify that the robot is running and connected. Right-click the tray icon and select Settings to verify:

 

46. RPA.png

 

If you look under Build -> Packages in RPA Hub, you should see your AES2RPA package there that we published from the RPA Desktop Design Studio earlier:

 

47. RPA Hub.png

 

We are now going to create a "Bot Process" which is an entity that consists of an RPA process (package), one or more robots and applicable credentials such as windows credentials or application credentials. Essentially, all the pieces needed to execute a "Bot Process" as a whole.

In RPA Hub select Build->Bot Process and click New. Fill out the details screen as seen below:

 

48. RPA Hub.png

 

It is IMPORTANT here to make sure that the Trigger Mode is set to API. Otherwise, you will not be able to execute the Bot Process on demand from the automation flow we are about to build.

Click Save and the rest of the configuration screens become available:

 

49. RPA Hub.png

 

The next part that we will configure is the Credential Set, in other words the username and password for the Windows Machine. This is required, so that the Robot can log in to the machine to execute the process.

It is IMPORTANT here that the Credential Set is available in a Global Scope and not in the application scope that you are in right now (AES2RPA). Please click the "Scope-Globe" in the upper right corner of the interface to change the current scope to Global before continuing:

 

50. RPA Hub.png

 

With this in place, move to the Credential Sets section and create the Windows Credentials as seen below:

 

51. RPA Hub.png

 

Click Save and ensure that the Application Scope of the Credential Set is in fact Global:

 

52. RPA Hub.png

 

Move to Assigned Robots and add the Robot we created earlier:

 

53. RPA Hub.png

 

Finally go to Process Robot Credentials and map together the credential set to the robot (i.e. the machine). You could have several credential sets for several machines hosting robots that all worked together on this process. That's why these settings exists (if you were wondering).

 

54. RPA Hub.png

 

This concludes the configuration of the Bot Process.

 

The last thing we need to configure in RPA Hub is the Queue. When a user creates a new record of type AES2RPA in our App, the record will enter this queue and sit there until a robot picks it up. Either on schedule or through API.

Go to RPA Hub Queues:

 

56. RPA Hub.png

 

Click New and configure as seen below. Give the queue a name and click Save:

 

57. RPA Hub.png

 

Now, we are going to assign the Bot Process to this queue so click on Bot Process (in the queue configuration) and Add the AES2RPA Bot Process. If you don't see the Bot Process in the selection when trying to add it, it's because you have clicked "Publish" in the Bot Process and it is therefore not open for modification. To remedy this, simply go back to the Bot Process and put it in Maintenance Mode, then add it to the Queue:

 

58. RPA Hub.png

 

Save the Queue configuration, go back to the Bot Process and "Publish" it:

 

59. RPA Hub.png

 

And that concludes the configuration of RPA Hub.

 

4. Designing the automation flow:

 

In App Engine Studio we will now add "Logic and Automation" to our app. This is where the magic happens behind the scenes when a record is created, updated or other triggers are executed.

Logic and Automation is designed using Flow Designer and may comprise of both internal ServiceNow activities such as updating other records or sending notifications or external activities in third-party systems through our numerous integration spokes.

 

In the App Home screen, locate Logic and Automation and click Add:

 

60. AES.png

 

On the next screen, select "Flow":

 

61. AES.png

 

Now you can see a collection of prebuilt Flows that are commonly used and provided for your convenience. We will however create a new Flow ourselves i.e. "Build from scratch":

 

62. AES.png

 

Give the new Flow a name. I have named it "AES2RPAValues Created", other options could be "Conclude AES2RPA entry" or whatever makes sense to you or conforms with your organizational conventions.

 

63. Flow.png

 

On the next screen, ServiceNow tell you that the Flow is ready to go. We still need to add the logic though, so click "Edit this flow":

 

64. Flow.png

 

We are now in the Flow Designer which is an essential part of building on, and expanding functionality of the ServiceNow platform. On the left, you can configure the trigger and all the subsequent actions and flow logic and on the right you have access to "Data Pills" representing the data and records that are available throughout the Flow.

 

65. Flow.png

 

First, we are going to configure the Trigger. For this flow, as mentioned earlier, the trigger will "fire" when a new record of type AES2RPAValues is created i.e. when the user clicks Submit. Configure as seen below:

 

66. Flow.png

 

When clicking Done, notice that you now have access to the Data Pills that represent the record that would have been just created and related metadata. 

Now add an Action. Search for rpa, locate the RPA Hub Spoke and select "Add WorkItem to Queue".

 

67. Flow.png

 

Configure as seen below. The queue name is the queue that we have just created in RPA Hub i.e. "AESRPAQueue". The Name (of the item) must be unique, so I am combining AESRPA_ with the sys_id of the record. Expand the AES2RPAValues Record on the right and drag the sys_id into the configuration textbox.

Note that the Content of the WorkItem is JSON notation with the familiar structure {"name":"value","name","value"}, so in this case it is {"textvalue": "<Data Pill with TextValue>", "numbervalue": "<Data Pill with NumberValue>"}. With this in place, click Done.

 

68. Flow.png

 

Now the record has been added to the queue, waiting for a robot to pick it up. We will just do that right away by starting the Bot Process that we have created. Next action in the Flow is RPA Hub->Start Process.

 

69. Flow.png

 

Select process name (AES2RPA) and the name of the robot. In my case it's called Badge Printing. Please adjust to the name of your Robot record created earlier if it's different. Then click Done.

 

This concludes the design of the Flow. We are now going to test it. Click "Test":

 

70. Flow.png

 

In the test window, you can select an existing record or create one for the test. As we don't have any records in the table at this point, we will create one, so click the plus symbol. Enter a text value and a number value.

 

71. Flow.png

 

Ensure that your "Unattended Robot" is running on the target machine (check the system tray):

 

72. RPA.png

 

Click "Run Test":

 

73. Flow.png

 

First time you execute the flow might take a little longer as the package is being sent to the target machine, logs are synchronized etc. but after a short while, you should (hopefully) see Notepad opening and your data being written:

 

74. RPA.png

 

Now our solution is complete. The flow is working as intended, so you can Activate it by clicking Activate. From now on, every time an AES2RPAValues record is created, this flow will execute.

 

75. AES.png

 

If you look at the Bot Process in RPA Hub, you can verify that an execution has in fact taken place and that is was successful.

 

76. RPA Hub.png

 

All together now:

 

 

I hope you enjoyed this exercise and that you find it useful. ServiceNow RPA is an excellent addition to App Engine when legacy systems need to be integrated into your flows.

 

One note, though, to consider... 

The approach taken in this example to start the RPA process "by force" at the end of the Flow may not suit all use-cases. The thing is that this action does not check or consider whether the robot is already in the midst of another execution. If this was the case, the running execution would stop and this execution would begin. There are several ways to work around this issue if needed. Please check out this article from my esteemed colleague @Daniel Draes describing ways to handle queues in ServiceNow RPA: RPA: Managing Work Queues with API triggered bots 

 

Comments
mahajanravish5
Tera Contributor

Hi Great Article, I have few questions here:

1) Do my clients have to install RPA studio on their system to make this work?

2) What other strong use cases can we have? 

jitesh_malik
ServiceNow Employee
ServiceNow Employee

Hi @mahajanravish5 

Regarding your question:

1. Yes, you will have to install the RPA studio to create the automation file (this can be installed on the developer system). Which will run using a run time that also needs to be installed on the machine which you want to use for automation.

2. You can use the RPA for working with other scenarios can be:

Financial Services - New account verification, Report creation, Change of address, etc.

HR - Employee onboarding/offboarding activities which as of now require manual data processing.

Telecome - Backing up information from client systems, Extracting data about competitor pricing, etc.

There are many more scenarios in which you can use RPA.

//Jitesh

Salvatore B
Tera Contributor

Hello,
thank you for the article!
I have a question:

  • I created the flow and when it is executed, it reports the stasus "Completed" but the bot doesn't run on the machine

do you know why I don't see it running on my machine?
This is the flow that was created:

SalvatoreB_0-1679665110544.png

 


Thank you!

jitesh_malik
ServiceNow Employee
ServiceNow Employee

@Salvatore B could you please validate if there is any record in the Process job table that is getting created when you run this flow?

Salvatore B
Tera Contributor

SalvatoreB_0-1679678369253.png

no records is created in process jobs;
just a little bit, when I try to connect the Unattended robot I receive this:

SalvatoreB_1-1679678569315.png

@jitesh_malik  any suggest?

Thank you!

 



jitesh_malik
ServiceNow Employee
ServiceNow Employee

@Salvatore B  There is license validation enforced on the RPA Product, you will have to go and create a new record in the "Robots License Distribution" first.

 

Please refer to the below docs for the same:

 

https://docs.servicenow.com/bundle/utah-integrate-applications/page/product/rpa-hub/concept/license-...

Salvatore B
Tera Contributor

Hello @jitesh_malik,
thanks but unfortunately I had already created a new record in the "Robot License Distribution":

SalvatoreB_0-1680180809808.png

 

jitesh_malik
ServiceNow Employee
ServiceNow Employee

Hi @Salvatore B 

 

The record shows that you have -ve available robots. This has to be corrected by the support team.

 

//Jitesh

Rafael Batistot
Kilo Patron

Hi,  thank you for shared your knowledge about RPA.
My doubt is, if i have a large flow created in RPA studio, can i operate other activitiesin my machine? Or while the RPA is running my machine will be useless? In case of large flow will be necessary a virtual machine? 

Thank you advanced

Version history
Last update:
‎01-27-2023 03:53 AM
Updated by:
Contributors