Use Case

Estimated reading: 5 minutes 1733 views

Creating an activity

Overview:

We are going to create an activity for the extraction of specific data from a JSON file within an automation solution. Previously, achieving this extraction required a workflow comprising 4 to 5 steps; however, with this custom activity, the process becomes more efficient and direct.

Use Case:

In this scenario, the activity reads a JSON file and extracts a specific value from it.

Steps to build the custom activity

1. Once you have created a project with “Robility Custom Activity” builder template, now navigate to the “Menu” bar.2
2. Click on the “Extensions” and choose the “Robility” from the drop-down menu.
3. Select the “Add Activity” to build and create a custom activity for our use case.
    a. A window labeled as “Add Activities” will appear on the screen.

4. Upon selecting the “Create” option, you will be navigated to define the activities name for the feature that we are about to create.
    a. In this case, we are creating only one activity and let’s name it as “Json Reader”.
    b. Click on the “Add” option and enter the name in the box.
    c. Let’s provide a description of the activity as “Helps to extract specific details from the provided JSON input.
    d. If you want to add multiple activities, click on “Add” button and define them.

Creating Properties

This is the most crucial step where we define the basic structure for the properties required for the activity. These properties determine how the input and output values should be provided.

A. Define Input Properties:

Input properties specify the data that the activity will receive. In this use case, we require the following input properties,

1. InputText – This is used to provide the input JSON text value in “String” format from which the specified extracted value needs to be retrieved.
2. ExtractionValue – This is used to provide the “Value” that needs to be extracted from the JSON input text.

Now, let’s see how to define these properties.

1. To launch the “Define Properties” window, select the “Edit” option under the property in the define activities window.
2. Now, click on the “Add” button to create the property.
    a. Enter the property name as “InputText”.
    b. In the description, you can provide the properties description. Here the value is, “Provide the input JSON value in String format”.
    c. Now, move to the next field, “Direction”. Since this property is used to retrieve the value as input. The direction needs to be set as “IN”.
    d. Next, in the “TYPE” field defines the datatype of the property that needs to be accepted when the user provides the input value. Here choose the value as “String”.
    e. Make this property as “Mandatory” by toggling the “required” option.

3. Now, let’s define the next property, “ExtractionValue”.
    a. Click on the “Add” button at the bottom of the window.
    b. Enter the property name as “ExtractionValue”.
    c. In the description, you can provide the properties description. Here the value is, “Provide the value that needs to be extracted from the JSON value in String format”.
    d. Now, move to the next field, “Direction”. Since this property is used to retrieve the value as input. The direction needs to be set as “IN”.
    e. Next, in the “TYPE” field defines the datatype of the property that needs to be accepted when the user provides the input value. Here choose the value as “String”.
    f. Make this property as “Mandatory” by toggling the “required” option.

B. Define Output Properties:

Output properties specify the data that the activity will provide as result. In this use case, we require the following output property,

1. JsonValue – This is used to return the value that is provided as input from the JSON text value in “String” format.

Now, let’s see how to define these properties.

1. In the “Define Properties” window, click on the “Add” button and in the “Category” list, choose the value as “Output”.
    a. Enter the property name as “OutText”.
    b. In the description, you can provide the properties description. Here the value is, “Declare a variable to view the output in String format”.
    c. Now, move to the next field, “Direction”. Since this property is used to retrieve the value as input, the direction needs to be set as “OUT”.
    d. Next, in the “TYPE” field defines the datatype of the property that needs to be accepted when the user provides the input value. Here choose the value as “String”.
    e. Make this property as “Mandatory” by toggling the “required” option.

C. Provide the custom code:

Once you select the “Finish” button, the activity’s code with all the properties will be created. In that code, you can add the custom logic that needs to be performed. Let’s see how to input your custom code:

1. In the “Code Editor,” you can view the default code template with all the activity arguments defined.
2. In the “Execution” section, you will see “Add your logic here.” In that area, provide your code. 
    a. Refer to the attached code.
    b. Now, you can save the code.

D. Create the nuget package:

1. Now, right click on the “Solution” name in the solution explorer.
2. Choose “Build” option to create the nuget package.
3. The path where the nuget package will be saved will be available in the below toolbox.

E. Utilizing the activity in Robility Designer:

Let’s use the created package in the Designer to view how the activity works.

1. Launch the designer and create a solution.
2. Click on the “ManageFeatures” option in the Designer to install our package.
3. Navigate to the “Browse” option.
    a. This option is used to install the nuget package that aren’t available in the Designer.
    b. Here we are using this option to install our nuget package.
    c. Now, browse and install the package, the feature will be available in the “Toolbox”.

5. Drag and drop the activity and pass the required input in the properties.

Below is the sample output of the execution of the activity,

Share this Doc

Use Case

Or copy link

CONTENTS