Coded Workflow Services for UiPath Libraries

Hey Team!

Love the work with coded workflows so far! As I am thinking through best practices for coded automations/workflows, one thing I noticed was that it seems like its not really possible to reference Library-output type projects via coded workflows. What I mean specifically:

  1. I create a Library-output project in UiPath Studio, create some activities for it, and publish it.
  2. I import the above library in a Process-output project in UiPath Studio. It seems that I am unable to then reference the activities I created in my library within Coded Workflows.

I know that the way that the coded workflows work is through a public partial class ‘CodedWorkflow’, that you are able to inject services into via DI (like ‘system’, ‘testing’, etc.), but I’m not sure how to even reference, let alone execute, the activities generated from the library.

Not sure if there’s a workaround for this yet, but it would help make things consistent :slight_smile:

Thanks,
Yash

1 Like

Did you ever get this answered, I’d be happy to back and forth if you still need help.

2 Likes

I believe this is resolved on the current stable version!

Might need to reload project or something after initially adding the library dependency but you should be able to access referenced UiPath Library activities via a service just like system or testing. I believe it gets added to the base CodedWorkflow class as a member/lazily initialized DI service through reflection/registration pattern.

Ie.
Library name: My Library
Coded Workflow Reference: my_Library/myLibrary or some other safe transformation. I was able to see it in the intellisense with ctrl + space in any CodedWorkflow derived class.

Note that I always create activity metadata for my libraries, and have not tested it in the scenario that activities in libraries are created without it.

1 Like

@eyashb
Please, can you explain the way how to proceed a bit more? Thanks

On 25.10; not sure when this got added in:

My Library

Once installed in a process:

Once you clear local cache/reload project, your CodedWorkflow in project/.local/.codedworkflows/CodedWorkflow.cs should have the below snippets in it

//  private member declaration
        private Lazy<global::UiAutomationTools.WorkflowRunnerService> _uiAutomationToolsLazy;

// And protected accessor that resolves it from the CodedWorkflow Service container
// the property name here will be how to refer to it (ie. uiAutomationTools)
        protected global::UiAutomationTools.WorkflowRunnerService uiAutomationTools => _uiAutomationToolsLazy.Value;

If that isn’t being generated by itself, you can try manually adding those lines inside a public partial class called CodedWorkflow in your project’s root namespace, but not sure if that will work because the service is initialized by UiPath.