Nia McCash
Mega Sage
Mega Sage

I am new to the Robotic Process Automation (RPA) concept and I like learning by example so the #BuildWithRPA Challenge was a great opportunity for me to learn all about RPA.

 

First: a little about my learning process... 

 

I learn best by seeing an example and watching walkthrough demos. For me, it beats reading through documentation. 

 

In thinking about building an RPA for my own use cases, I thought about what I would have to replicate from the lab to get my own RPA bot working. For me, copying the lab and tweaking things a little bit at a time made more sense as a starting point for learning and implementation, instead of starting from scratch. 

 

So, I started by replicating the lab in my PDI. Instead of automating a Badge Tool, I tried opening up a website, clicking on the search icon, and running a search on some text that came from my instance.

 

If, like me, you learn to implement new features by following an example then tweaking it bit by bit, then this post will help you apply and replicate some of what we learned in the challenge to our own PDI or instance.

 

Here are the things that are pre-built/pre-configured in the Lab that we would have to replicate for our own instance's bot

 

  1. Send Data to Robot button/UI Action:
    NiaMcCash_0-1694108469961.png
    This button creates the Work Queue Item [sn_rpa_fdn_work_queue_item] that the bot would pick up. This Work Queue Item contains the data for the bot to use as a JSON payload in its Request Content field.

    If I were building this for my own RPA/robot, I would label this something more user friendly like “Auto Print Badge” or something like that. The label could be different depending on your bot’s use case.

    Let’s break this down because this UI Action consists of 2 additional configs that we will need to replicate.

    First, let’s look at the UI action code:
    (function() {
    	
    	try {
    		var inputs = {};
    		inputs['visitor_data_record'] = current; // GlideRecord of table: x_snc_visitor_ma_1_visitor 
    				
    		// Execute Synchronously: Run in foreground. Code snippet has access to outputs.
    		var result = sn_fd.FlowAPI.getRunner().subflow('x_snc_visitor_ma_1.send_visitor_data_to_robot_queue').inForeground().withInputs(inputs).run();
    		var outputs = result.getOutputs();
    
    		// Current subflow has no outputs defined.		
    	} catch (ex) {
    		var message = ex.getMessage();
    		gs.error(message);
    	}
    	
    })();
    Note that the UI Action calls a subflow.
    So, we’ll also need to replicate the subflow…

    1. The subflow takes the record in question as an input:
      NiaMcCash_2-1694108469726.png

      And has two actions, the first of which is a custom action and the second is an out-of-box (OOB) action that is ready for us to use.

      NiaMcCash_3-1694108469740.png

       

      So, we’ll also have to replicate the first action…

    2. The action takes the record in question as input:
      NiaMcCash_4-1694108469737.png

       

      and builds the JSON string and returns it as the output.
      NiaMcCash_1-1694117600859.png

       

      Alternatively, you can skip the custom action and build the JSON in the Add Work Item to Queue action. Example:
      NiaMcCash_0-1694199828414.png

  2. We also have to create the Bot Process Configuration [sn_rpa_fdn_bot_process_config] record and then connect that Bot Process Configuration with the Work Queue by via a Process Queue [sn_rpa_fdn_m2m_process_queue] record.

    This is to replicate the Setup RPA Hub and Unattended Robot steps of the lab. Note that in the lab, the Visitor Bot Config is ready to be selected when you select Assign Configuration.

    NiaMcCash_0-1694118373254.png

     

    Our bot may not be in the Create Bot Process as shown here until we perform this step.

    To create the Bot Process Configuration [sn_rpa_fdn_bot_process_config] record and connect it with the Work Queue by via a Process Queue [sn_rpa_fdn_m2m_process_queue] record, see the instructions in the official docs: https://docs.servicenow.com/bundle/vancouver-integrate-applications/page/product/rpa-hub/concept/cre... and ttps://docs.servicenow.com/bundle/vancouver-integrate-applications/page/product/rpa-hub/task/create-...
     
  3. We also need to create the user with the sn_rpa_fdn.rpa_robot role. The lab guide specifically says this user has been created in our lab instance.

    NiaMcCash_0-1694204980933.png

     

    Additionally, we may need to set the PDI’s instance and robot authentication mechanism if using basic authentication as the lab does.

    When I tried basic authentication with the user I created on my PDI, I found that I couldn’t authenticate and had to set the sn_rpa_fdn.instance_authentication System Property to ‘basic’.

 

And there you have it. If you did the lab, found it helpful, and are using it as a starting point to create your own automation, hopefully the above helped you get started.

If this post helped you, I would appreciate it if you marked it as 👍 helpful.

Version history
Last update:
‎09-12-2023 06:19 AM
Updated by:
Contributors