Cannot use UiPath activities via code

Hey,

So I’m not sure if I’m doing this incorrectly, or this just isn’t something supported with UiPath.

What I’m trying to do: Create a wrapper for all UiPath.System.Activities that accept a Dictionary<String, InArgument> so that we do not have to manually create those dictionaries in Studio, but can dynamically update them as the process develops. Currently, I’m only targetting Set Transaction Status and Add Log Fields.

I had difficulty in doing this and the steps below are for a Log Message activity.

Steps:

  1. lmActivity = new UiPath.Core.Activities.AddLogFields()
  2. activityArguments = new Dictionary(Of String, Object)
  3. lmActivity.Message = new InArgument((object)(“Testing…”))
  4. activityArguments(“Message”) = new InArgument((object)(“Testing…”))
  5. lmActivity.Level = new InArgument(LogLevel.Info)
  6. activitiyArguments(“Level”) = LogLevel.Info
  7. result = WorkflowInvoker.Invoke(lmActivity, activityArguments) → Error Here

The error I keep getting is “Assign: Object reference not set to an instance of an object.”

Check Robot API to invoke functionalities Robot API. Do not try to wrap UiPath activities.

Fair enough, I realize why wrapping UiPath activities probably is actively discouraged for security reasons.

But please, update any activities that require us to manually hard-code log fields/output data/etc. to allow a dynamic dictionary.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.

Hi @eyashb

Do you have any activities in particular in mind?

Hey, sorry about the late response!

I think there were only 2 on my mind:

  1. UiPath.Core.Activities.SetTransactionStatus - Analytics and Output fields; P.S on this activity’s note, is there a reason why you can’t set these on exceptions? Feels annoying to JsonConvert from Exception Details if we want to preserve state-dependent data for transactions between retries. Am I just dumb? Is there another way to achieve this functionality?

  2. UiPath.Core.Activities.AddLogFields - Fields should be able to be dynamic?

1 Like

Thank you for clarifying. We should indeed have a look, given that we try to allow users to parametrize as much as possible in their workflows. I saved it for our team to consider.

As to the:

Could you maybe explain your issue here with a screenshot? I will admit that I didn’t play around with this particular activity much to immediately get the issue here.

Okay so this activity is the one that is used to update the status of a queue item to orchestrator from a robot.

There are 2 different meaningful statuses that the queue items can be: Successful and Failed.

From my experience, I’ve been able to set the Analytics and Output fields when an item is successful, allowing us to update that queue item with information at the end of the transaction (ie. saving the order # after creating an order)

Thing is, when implementing retries, if you have other steps past saving the order # and it failed at one of those steps, you don’t want to keep making new orders, you’d want to retain that order number and maybe other information to start off where you left off.

Based on the current activity, we only have reason, and details that we can customize to be able to retain that state-dependent information.

It would be nice to be able to have a dictionary that we can set for failed transactions as well so that we can retain data in a convenient manner.

I already have workarounds for this one, so it’s not too big a deal.

Hope that helped add some context!

1 Like

Thanks for the detailed explanation and a use case, much appreciated :slight_smile: We will consider it for the future.