Using Functions in UIPath

Hello.
There is a need to use a large piece of code several times.
Is it possible to write a function and call it as needed?
I will give an example from java.
//Function Description
function sum(a, b) {

  • sum = a + b;*
  • console.log(sum);*
    }
    //Function call
    sum(a, b);

Necessary:

  1. pass value to function
  2. Process value
  3. return result
1 Like

Hey @Andrey_VIctorov

You can create a new project file → Click new and choose Sequence or Flowchart

Once the above is created you can create Arguments through which data can be passed

The workflow which you created now can be drag dropped into any other program files to call that as a function or use Invoke Workflow activity

Post that you can click on Import Args to send some data into file or get data out from it

Thanks
#nK

1 Like

on the viewpoint of reusability we do have following options:

  • XAML files used within an invoke workflow file activity

  • Custom Libraries
    About Libraries

  • Custom Activities:
    Using The Activity Creator

  • nuget packages providing compiled artifacts

  • with some tricks: Actions

1 Like

Hi,

We can achieve it using Func type as the following.

Regards,