Skip to main content

Adding C# methods with a script component

Suggest edit Updated on November 10, 2021

A script component lets you add custom C# methods to your solutions for advanced functionality or situations where interrogation or recording isn't possible or sufficient.

Note: The system automatically stores the script component in the Globals container, which is necessary for other automations in the project to reference the component.

You might use this advanced feature when you have existing C# methods you want to leverage, for example. When you add a script component to a solution and create at least one method for the script, Pega Robot Studio creates an assembly file (Script-identifier.dll) for the script component. This file, along with the DLL files that are required for any of the other Robot Studio components that generate dynamic assemblies, are stored in the user's %LocalAppData% folder. Robot Studio uses these assembly files during project design only. When you create a runtime deployment package for the project, the dynamic assembly of the project contains all the required component assemblies.

  1. In the Project Explorer, click the Globals container.
  2. In the Toolbox Search field, enter Script.
  3. Click and drag the Script component to the Automation Surface.
  4. Right-click the Script component, and then select Edit script.Result: The script editor opens, as shown in the following figure:
    Script editor in Robot Studio
    Editor for the script component to add C# code methods.
  5. Add your custom C# methods, and then click Save.
  6. Optional: To specify any external assemblies that the code requires, click Manage references and add the assemblies.
    You can add assemblies from any of the following locations:
    • .NET (GAC or Global Assembly Cache)
    • Pega (installation folder)
    • PublicAssemblies folder (in AppData)
  7. Click Validate to compile the script and test the syntax of your C# code.Result: The script editor highlights incorrect syntax so that you can edit the code.
Did you find this content helpful? YesNo

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Ready to crush complexity?

Experience the benefits of Pega Community when you log in.

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us