How to create a "select file" or "select folder" element in new UiPath Forms

I finally figured this out!

Add a Text Field to your form, Field Key is file. Set it to disabled (optional).

Add a button, Action is event, Field Key is selectFile, label is Select File.

Now mouse over the button and click the Create Trigger icon:

image

Name the form trigger and click Create:

image

In the Form trigger activity, choose “Select File clicked” for Event:

image

Add a Browse For File activity, output the path to SelectedFile:

image

Add a Set Form Values activity.

image

In the Dictionary, assign the SelectedFile value to the file object:

image

NOTE: If the Arguments field is locked/disabled, add a value to (or remove the value from) the Instance Name field. The change in this field seems to trigger unlocking the Arguments.

Now your Select File trigger looks like this:

Make sure you have a Run Local Triggers after you display the form:

image

Run your automation, click the Select File button, select a file (sometimes the window appears behind others and you have to look for it), and then click Open, and VOILA now you have a text box on the form that has the file path in it!

image

2 Likes

Thanks Paul, mean it!

2 Likes

Thanks for the screenshots and the walkthrough @postwick .

I was able to do everything except getting back the value(file oath) as you have shown ‘file = SelectedFile’. I believe once clicked on “continue workflow execution”, bot has already passed the ‘Show Form’ screen where the actual variable was supposed to be assigned. Basically I need help me retrieving the value back in the Main Flow where show form was called. Let me know if anyone has the answer or encountered the same issue. thanks

1 Like

Use the Get Form Values activity.

1 Like

The problem was the Submit button next to Select File button. I changed it to a simple button and get form values, everything working now. Thank you!!

2 Likes

Ahhh yes, that’s a great point I should have included. You never want to use a Submit button on the new forms, you won’t be able to get the values that were on the form when it was submitted - because the Submit button closes the form.

Change it to an event button and create a Trigger for the button. Then in the Trigger you can Get Form Values, and the Close Form.

1 Like

Hi @postwick, trying to include a file picker in my Form activity. I followed the steps laid out above, but I’m running into an issue:

Whenever I click “Submit”, the “Browse for File” window pops up again after the form is already closed, prompting me to select another file. However, if I try to select the file again, the bot errors out because the form has already been closed. It’s as if the bot is running through the Select File trigger again, even though I only clicked the button once.

Alternatively, if I try the method you mentioned of changing the submit button to an event, and setting the trigger to Get Form Values and Close form, the bot simply does not continue with the workflow. The form closes, but nothing else happens until I manually force stop the bot. This also happens if I try changing the trigger scheduling to “One Time” instead of “Sequential”.

It seems no matter what I try, I can’t get the bot to continue the workflow after the Form is closed. Can you please assist?

Thanks so much,
Noah

Is the code that you’re expecting to run after the Run Local Triggers activity? If so, that’s your problem. You have to think of it as all your code needs to run from a Trigger XAML, triggered by something happening. Or if there is nothing else for the user to do in the form, after the trigger code you have to end local triggers.

Ahh that was my issue. I just needed to add a Stop Local Triggers and that solved my issue.

Thanks so much!

1 Like

Yeah this style of automation is somewhat unique in that it’s more like building an application - it runs up until the Run Local Triggers then pauses there waiting for user input. Then you have trigger code that responds to each user input, and once there is no more user input expected you Stop Local Triggers so it’ll continue and complete processing. This is all very useful and I’ve built some complex attended automations using it.