How to get the current running Xaml file name dynamically

Uncheck filter activities.

Just one small correction - this returns the class name of the root (IIRC correctly), so if you rename the workflow it may not be accurate.

1 Like

I didn’t not check the package yet will do in sometime, is it the x:Class attribute that you mentioned. I tried to read that value multiple times in the past , but failed.

I had issues with getting to it in the past as well directly from xaml, but in the end managed to by checking attributes with names extended with namespaces. Don’t have access to that one right now, but I’ll try to send you some pointers tomorrow.

The package though uses WorkflowInstance as you can check in the link. I don’t guarantee that it will not collide with something Uipath does internally, as I don’t have visibility over that, but in short tests it worked correctly.
If it will be functionally ok, I’ll clean it up and add to my repo. Still need to setup builds and feed for that one, but never enough time…

Cool, it worked. But I tried renaming Workflow and it still worked for me bringing in correct name.

Now, how do you get Arguments passed when the workflow throws an error? If that part can work, I’ll be happier, since you can’t pass the Workflow name if it errors.

1 Like

Interesting… I thought it wouldnt. I’ll need to investigate further on that one. But that’s even better :slight_smile:

With the arguments it’s tough. There is a trick with double reference, but that is hackish as hell, since arguments not passing is by design.
Or that may be a case for app resources… @vvaidya?

Possible, but we need to refer the values twice (Arguments and App Resources). As far as @ClaytonM 's question is concerned , why not save the Page name using your activity in App Resources at the beginning of of every workflow ( as 1st activity) that way we always have the page name of Last accessed Workflow.

System.Windows.Application.Current.Resources("wfname") = wfName


In the catch Block you can get the workflow name as below

strErrorWf = System.Windows.Application.Current.Resources("wfname").ToString


Hi Andrzej, would you be kind enough to share the source code?

(please do excuse me for shamelessly asking for this … :wink: )

1 Like

Hey @andrzej.kniola,

This is brilliant :smiley: I have been looking for it for quite sometime now. I am building a custom activity that needs to retrieve the name of the workflow for some reporting. Do you mind sharing the code?

Rammohan B.

@andrzej.kniola you truly are wonderful!

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.

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 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.



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



@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.


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?


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: