How to get the current running Xaml file name dynamically

uiautomation
activities

#1

How to get the current running Xaml file name dynamically.


How to get dynamically physical Xaml file name of currently running
How to get Flowchart or Squence name
#2

Hi.

Don’t think it can be done.
But one thing you might consider is storing all the .xaml filepaths that you wish to invoke into variables or an array, then you can use that in your Invoke Workflow to call it and you can tell which part of the process you are currently at.

You can also use System.Environment.CurrentDirectory (or Directory.GetCurrentDirectory) and Directory.GetFiles() to gather the .xamls located in the folder. And, if your filenames are named where they are in the order of the process, you can store them into a list and use that list in your Invokes.

Another tip is you can get the filename only by using Path.GetFileName(), but requires a fullpath I think. Or you can also use a .Split like filepathvariable.Split("\"c).Last

Regards.


#3

Hi ClaytonM,
Thank you for your reply. I will try it.


#4

Could you check with this one? Activity name GetRootActivity
GetParent.1.0.5.nupkg (5.3 KB)
Not sure if this is what you’d need, but tests looked good yesterday.
Based on this and modified a little.
Don’t mind the package/activity name, I was actually trying to do something else and ended up with getting the xaml name… happens :stuck_out_tongue:


Get File Name of the xaml file which is currently running
How to get current xaml name
Component/Sequence/Workflow Name
#5

For some reason your .nupkg will not load into my Activity Packages to install, even though I placed it in the same folder as the other ones I have installed. :man_shrugging:


#6

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.


#7

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.


#8

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…


#9

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.


#10

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?


#11

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

image

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

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


Running bot details
Set current Directory issue
#12

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

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


#13

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?

Thanks,
Rammohan B.


#14

@andrzej.kniola you truly are wonderful!


#15

Hi, what input is expected for RootName ?

Thanks
Mohini