How to get the current running Xaml file name dynamically

Hi could one of you please share the code this is exactly what I need?

Hi @vvaidya @ClaytonM

Which is the best solution to get the Workflow name dynamically.

Regards
Baskaran C

The “best solution” can be debatable I think.
First, we must define what we mean by “dynamic”.

Essentially, you will have a series of workflows being implemented in your process. A good practice would have these filepaths to these workflows stored in a global variable (or config file). Now, you have the workflow names because they are stored in a variable.

However, do you want the workflow name(s) or do you want the name of the task being performed so you can log this information? So, the workflow name won’t necessarily give you the name of the task being performed if you have multiple tasks in one workflow. But, then again, it might not be good practice to have multiple tasks in one workflow anyway.

So, simply put, you can store the task names for a process in some array or variable which you can reference before you invoke each workflow file that you want to log. For example, you can log that the particular task is starting.
^That is one approach, which I find a little more flexible to be honest

The other approach would be to look in andrzej’s and vvaidya’s posts above as they provide you a way to store the current workflow file being run into a variable. If you take this approach you must surround the workflow’s main sequence with a Try/Catch. Therefore, the Error Handling becomes redundant since any framework used to invoke that workflow would also be handling the errors. —arguments can not be passed when an exception is thrown, so you wouldn’t be able to pass the workflow name without it going through a Try/Catch. This also requires that all reusable workflow components that you might want to return the workflow name from include a Try/Catch, which means any RPA devs would need to know this and a lack of versatility I think anyway.

@baskaran.c Hi, so those are a couple ideas on how to handle workflow or task name(s) storage dynamically in order to provide that info in your logging.

  1. store a list of tasks in an array that will be performed; store the current task into a variable before each workflow task is invoked so when an exception is thrown on that workflow, you have the current task that was being performed
  2. use vb.net code to return the .Current.Resources(“wfname”) -as shown earlier in this topic- at the start of each workflow and pass it as argument by using a Try/Catch around that workflow’s main sequence; also pass the exception in the Catch so your framework main can see that an exception occurred.

Regards.

4 Likes

Hi guys,
for this case you can use my new developed Alphabet.Workflow.Activities
downloadable via Community-Activities in your package-manager.
UiPath Gallery Link

It contains activities for example to get:

  • the xaml filename
  • the parent workflow name
  • the root workflow name

regards
Markus

7 Likes

@andrzej.kniola. This works perfectly fine. Thanks.

Would you mind to explain each part of the code you used in your package I am just trying to understand its functionality as i trying to build something more complex then this for the custom reporting. thanks in advance

Hey @mwerner I tried to use your library Alphabet.Workflow.Activities and it works perfectly for getting the Xaml file name but I also tried to use the other activities under Logging (e.g. Log Start Of Workflow) and they do not work under UiPathStudio Version 2020.4.3 when I move of of this actities to a workflow, following exception appears:

Exception screenshot:

What could be the reason? Wrong version of UiPath.Core.Activities.LogMessage package? I am using version 20.4.0.

2 Likes

Hi @Phipsll i just tested the activities with the newest version 2020.10 (BETA) and everything is working. Which version of Workflow.Activities are you using?

1 Like

Hello @mwerner thank you for your fast response. I am using version 3.1.0 of Workflow Activities, more details you can take from the screenshot below. As a workaround, I have downgraded UiPath.System.Activities to version 19.8.0 that the logging activities work again.

P.S: My licence for UiPath Studio is only limited to version 2020.4.3 and is not possible to upgrade as far as I know.

1 Like

I was the same! Obtaining file name was great but the Logging tools do not work and I received the same error. I’ve just done my logging so it will probably be the same result as what that product originally offered?
image

2 Likes

Yes this works as workaround for me too and I already use this but I am not really happy with that to be honest. :slight_smile:

2 Likes

Hi there, i’m currently in process of uploading a new version which solves this problem. Stay tuned :slight_smile:

3 Likes

Hi @mwerner, thank you for your fast action and solving this problem by uploading Version 3.2.0. No the activities are working with UiPath.System.Activities Version 20.4.0 but there is still a minor bug that you have swapped Prefix and Suffix Input. More details can be seen on the screenshot below.

I thank you for your effort!

2 Likes

Thanks Markus for sharing this useful package.

1 Like

@mwerner
Thanks for the easy to use package, but would also like to share our experience using it.

We did use the package to get the current worfklow name in our library workflows. Turns out that, when the library is built and imported into a REFramework things dont work out.

Tldr: Alphabet Package checks for the workflow being run on runtime and not the workflow you actually wanted to log. This occurs when using the “Get xaml file name” activity in a library acitivity and when consuming the activity in a REFramework.

Details:

  1. Create a library: Library_x → Dependencies → Alphabet Workflow Activities
  2. In the library_x created workflow “Add.xaml” - Placed a “Get xaml file name” activity. And log message.
  3. Test: Works as expected. Returns the current workflow name i.e., “Add”.
  4. Build the library_x.nupkg
  5. Import library.nupkg and use in REFramework
  6. Used the library_x activity “Add” in the “Process.xaml” in REFramework.
  7. When the REFramework is run the logs show “Prosess” as file name instead of “Add” (which is where the “Get xaml file name” resides).

Our current solution to get the filename:
In the end, we had to uninstall Alphabet and update 40 workflows manually. Out approach was to go to the basics and hardcode the filename.

Assign —>out_ThisFileName = “CurrentFileName.xaml”

2 Likes

Hi there! At last, were you able to get any other solution for this? This is giving me big time headache as well…

Thanks!

Thanks for this solution,it is working perfectly …

When I use the get xaml name both from the alphabet package and the getparent package i just get the return as dynamicactivity and its a xaml ran from inside another xaml, could anyone offer some help?

I’m experiencing the same issue . It return “DynamicActivity” when running Invoke workflow file. Is there any workaround?

1 Like

In the UiPath.System.Activities activity package (checked against the version 21.10.4) there’s the activity “Get Current Job Info” that returns an object of type CurrentJobInfo.

CurrentJobInfo has a member property by the name WorkflowName that contains the name of the currently executing workflow file without its .xaml extension.

4 Likes