Daniel Draes
ServiceNow Employee
ServiceNow Employee

So this is my second approach on solving RPABOTS.WORLD challenge #1 . The main ask in this challenge is to create invoices based on data available in CSV File & Send Email along with Invoice to account teams for quick reconciliation. I modified this a bit to make it more fit the idea of a workflow platform. My revised mission statement is:

 

The goal of this RPA Challenge is to create invoices based on data created and maintained in ServiceNow custom tables and attach the generated invoice as PDF file to the ServiceNow record.

 

This involves building a small custom app to enter invoice data, some flows for capturing the data and sending it to a robot. The robot then does - like in the original ask - create and download the invoice. Additionally it will upload the PDF file to ServiceNow.

 

Let's have a look at the different components.

 

Custom application

I created a new custom application in App Engine Studio. This custom application basically hosts all data and logic required. The most elemental pieces are two tables: Invoices and Line Items. For the sake of this demo I did not use any parent tables.

Daniel_Draes_0-1669640830226.png

Invoice holds the header data for our invoice like number, customer, discount, total price and state.

Line Item holds the individual items sold as part of an invoice. So it needs a reference to invoice in addition to fields like product, price and quantity.

A created invoice would look something like this:

Daniel_Draes_1-1669641053754.png

 

 

Process logic

In order to move an invoice to the backend system and generate the PDF we need to trigger the robots. Nothing better than adding a flow. I choose to implement a simple state model for invoices: New, Processed, Payed. With that I picked a status change to 'processed' as my trigger - you could imagine any kind of ServiceNow powered flow to be crafted, i.e. approvals, data validations etc.

The most tricky part is to combine all relevant information into something our robot understands. Lots of options, but I went with a hand-crafted JSON structure, based on RPA: Exchanging data between the ServiceNow instance and you robot. 

The flow is short and simple:

 

Daniel_Draes_2-1669641404519.png

 

It first looks up all line items and creates the JSON string as variable. Basically it adds line items one by one to the variable in order to get an array of items:

Daniel_Draes_3-1669641495038.png

This is then used when adding an item to a RPA Queue, adding the invoice header data together with the line_items variable:

Daniel_Draes_4-1669641536444.png

The resulting JSON string for above example looks like this:

 

{ "sys_id": "69b036ae1b8a1d1013de99f1b24bcbdc", "number":  "INV0001005", "customer": "Sanjay Jain", "discount": "CHF 24.4941", "line_items": [{ "product": "Crispy Kings Chicken", "price": "CHF 100.00", "quantity": "3", "total_cost": "CHF 300.00"}, { "product": "Chop Sticks", "price": "CHF 50.00", "quantity": "5", "total_cost": "CHF 250.00"}]}

 

 

The robot

I repurposed the robot I had before by removing the Excel part and adding the Queue handling. When the robot is triggered, it first needs to read from the RPA Queue for any item to be processed. The component already delivers the RequestContent which stores the JSON string created in the flow. This can be easily deserialised into a proper variables again:

 

Daniel_Draes_5-1669641843453.png

With this new try I was also preparing to receive more than one line item - the original Excel only holds one per invoice. To manage this I used the Table Connector and enter all line items into a table:

Daniel_Draes_6-1669642000938.png

After extracting and preparing all data from the JSON string it is the same as before, i.e. entering the data in the webform and downloading the PDF file. No changes - literaly.

 

Instead of sending an email, I upload the PDF invoice back to ServiceNow and - be nice to my VM - delete the file again. That concludes the robot, so it also updates the queue item in ServiceNow to say we are done and successful:

 

Daniel_Draes_7-1669642189008.png

 

Verdict

It didn't take much to refactor it, and I think this shows the power of combining RPA with the a strong workflow platform managing the process.

Having RPA Hub to manage all this is great, it allows a viewpoint on how well are bots used, is it still working or failing etc.

 

You can find my custom app at phifogg/rpachallenge1: Implementation with ServiceNow custom app (github.com)

and the robot file attached to this record. Feel free to check it out, fork and change as needed 😄

 

To have it fully automated I would also recommend to read RPA: Managing Work Queues with API triggered bots.

 

 

 

1 Comment