UiPath Custom Activity

UiPath Custom Activity to Generate a SSRS Report

The UiPath Custom Activity in this demo will generate a report that is hosted in SSRS and save it with a specific name in a specific location. (The report will be saved in a PDF format).  You should be able to create a Custom Activity for any other functionality that might be required where the current activities within UiPath does not meet your desired outcome.

Technologies that will be used to create the Custom Activity:

·       Visual Studio 2017

·       NuGet Package Explorer

Step 1

Open Visual Studio and create a new project.
Make sure to select ‘Class Library (.NET Framework)’
Give a descriptive name relevant to the project.

New Project - UIPath Custom Activity to Generate a SSRS Report

New Project

Step 2

Once the newly created project opens up, add 2 references:

·       System.Activities

·       System.ComponentModel.Composition

Also make sure to use/import the relevant namespaces.

02 - Add References - UIPath Custom Activity to Generate a SSRS Report

Add References

 

Step 3

The main class will need to inherit the abstract class CodeActivty.

Then you will create the Input and Output arguments.

Input argument example:

Note: the <RequiredArgument> attribute will force the user to provide a value when this custom activity is used within UIPath.

<Category(“Input”)>

<RequiredArgument>

Public Property ReportServer As InArgument(Of String)

Output argument example:

<Category(“Output”)>

Public Property OutputValue As OutArgument(Of String)

See Step 8 on how these Input and Output arguments will be used within UIPath.

03 - Input_Output Category - UIPath Custom Activity to Generate a SSRS Report

Input and Output Arguments

Step 4

Within the Execute procedure:
The Input arguments are retrieved which will be provided by the user through UIPath.
These Input values are used to set the following variables:

·       URLSSRS: This will be the URL that points to the relevant report within SSRS. It also states in which format the report should be saved as. (PDF in this example)

_ReportServer & “?/Reports+Project/” &

_SSRSReportName & “&Parameter1=” &

_ReportParameter & “&rs:Command=Renders&rs:Format=PDF”

In the URL string above:
_ReportServer will hold the report server name.
_SSRSReportName will hold the report name within SSRS.
_ReportParameter will hold the parameter value that needs to be passed to the report.
·       localFile: This will be the Directory path where the report will be saved to with the specific name provided.

_SaveToDirectory & “\” & _PDFREportName & “.pdf”

In the string above:
_SaveToDirectory will hold the directory path where the report will be saved to.
_PDFReportName will hold the name of what the report should be called.

These 2 variables are then passed to the custom DownLoadwebfile Procedure that will generate the report.

In this example there is also an Output argument called OutputValue.
Not that any output is really required in this method, it has just been added to show the functionality of the Output argument.
In this example it will just pass the URLSSRS variable value to the OutputValue argument that will be displayed when the UIPath process is executed later. (See Step 8)

04 - Execute Procedure - UIPath Custom Activity to Generate a SSRS Report

Execute Procedure

Step 5

Once all the previous steps have been completed.

Build the visual studio solution within Release.

05 - Build Project - UIPath Custom Activity to Generate a SSRS Report

Build Solution in Release

You should find the DLL created within the project’s Release folder:

06 - DLL Created - Copy- UIPath Custom Activity to Generate a SSRS Report

DLL Created

Step 6

Open NuGet Package Explorer.
Select ‘Create a new package’.

07 - NuGet Package Explorer - UIPath Custom Activity – Generate SSRS Report

Create New NuGet Package

Under the Package Contents window, right click and select ‘Add Lib Folder’.

08 - Add Lib Folder - UIPath Custom Activity – Generate SSRS Report

Add Lib Folder

Right click the ‘lib’ folder that appears under the Package Contents window and select ‘Add Existing File…’.

09 - Add Existing File - UIPath Custom Activity – Generate SSRS Report

Add Existing File

Navigate to the DLL file that was created under the Release folder. (Same path as when Visual Studio solution was built in Step 5)
Select dll file and click on Open button.

06 - DLL CreatedUIPath Custom Activity – Generate SSRS Report

Navigate to DLL

Under the Package Metadata window, select ‘Edit Metadata’.
Provide an Id name, Version and Description.
Note: The Id should contain the word Activities. This will let it appear within UIPath Package Manager.
Once done, click on the green button.

11 - Package Metadata - UIPath Custom Activity – Generate SSRS Report

Package Metadata

Select ‘File’ from the menu and select ‘Save As…’.
Select the path where you would like to save the package too. In this example it is saved to the same Release folder where the dll file exists.
After saving the package, you can close the NuGet Package Explorer.

12 - Save NuGet Package - UIPath Custom Activity – Generate SSRS Report

Save NuGet Package

Step 7

Open UIpath Studio and Create a new process.

13 - Provide UIPath Process - UIPath Custom Activity – Generate SSRS Report

Create UiPath Process

Once process is created, navigate to Start – Settings – Manage Sources.

14 - Manage Sources - UIPath Custom Activity – Generate SSRS Report

Manage Sources

Under the ‘User defined package sources’ window, add a new package source.
Name: Provide any name
Source: Point to the path where the NuGet package was saved to.

15 - Add Package Source - UIPath Custom Activity – Generate SSRS Report

Add New Package Source

Step 7

Once the new package source has been created, navigate back to the process Design window.
Select the Manage Packages option from the ribbon menu.
Within the Manage Packages window the package should be available.
In this example it is called ‘SSRS_Demo_Package’.
When you click on the package name you should see the NuGet package.
In this example it is called ‘DemoSSRSActivities’
Select this package. Click on Install and then on Save.

16 - Manage Packages - UIPath Custom Activity – Generate SSRS Report

Manage Packages

The custom activity should be available under the Activities window.

17 - Custom Activity - UIPath Custom Activity – Generate SSRS Report

Custom Activity

Step 8

Drag the Custom Activity onto the Design canvas.
When you select the Custom Activity on the Design canvas, you should see the following Input and Output properties. (These are the arguments that was created within the Visual Studio project (See Step 4))

Input:

·       PDFReportName

·       ReportParameter

·       ReportServer

·       SaveToDirectory

·       SSRSReportName

Output

·       OutputValue

18 - Input Output arguments - UIPath Custom Activity – Generate SSRS Report

Input & Output Arguments

An ‘OutputResult’ variable has been created to hold the OutputValue returned from the custom activity. This has been added within a ‘Write Line’ activity that will display the SSRS URL used within the custom activity.

19 - Ouput value - UIPath Custom Activity – Generate SSRS Report

Output Value

This SSRS URL points to the ‘Demo_Report’ hosted in the SSRS.

20 - Demo Report - UIPath Custom Activity – Generate SSRS Report

Demo Report in SSRS

Step 9

Once all the input arguments have been entered correctly, run the UIPath process.
When the process has completed, navigate to the directory path you entered against the ‘SaveToDirectory’ argument.
The PDF report, with the supplied name provided within the ‘PDFReportName’ argument should be available in the directory.

21 - PDF Generated Report - UIPath Custom Activity – Generate SSRS Report

PDF Generated Report

Thanks for taking the time to read this blog, we hope you found it useful. If you need further technical advice or support on UiPath or other low-code development platforms, get in-touch with one of our experts today.

Need further technical advice or support?

Contact Us

 

 

You may also like

Please complete the below form and a member of the Velocity IT team will call you back.



INSTANT ESTIMATE