Create multiple field input dialog

Hi Guys,

Is there a way to create an input dialog in which multiple data can be entered? I would like to “fill” all my variables in one go at the start up of the bot without having to go through 8 different popups.

Thanks!

L

2 Likes

I am not sure how to add multiple fields in input dialog, But if you have multiple input you can add values in excel sheet and read those value in your workflow. This approach will work if you are providing inputs when you start execution.

Thanks for your swift reply! I would however prefer a more user friendly / presentable / slick option to enter the data. Would imagine that multiple fields leading to multiple strings shouldn’t be too much of an issue?

1 Like

I don’t think so it possible as of now.
Only thing you can do is reduce number of activity in the workflow by making use of list and collection but same input dialog will appear every time.

1 Like

Is there any plan to address this in future releases?

Probably, this seems to be quite a popular request that keeps coming back.

In the meantime (and since I can’t sleep for w/e reason :frowning: ) here’s a base to expand upon and customize for your needs:

Messy code inside
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Activities;

namespace WebHelpers.InputHelpers
{
    public sealed class MultiDialogActivity : CodeActivity
    {
        [RequiredArgument]
        public InArgument<Dictionary<string, string[]>> Controls { get; set; }

        [RequiredArgument]
        public InArgument<string> Title { get; set; }

        public OutArgument<Dictionary<string, string>> InputResults { get; set; }

        private Dictionary<string, string> results;
        private List<Control> formControls;
        private Form form;

        protected override void Execute(CodeActivityContext context)
        {
            var controls = Controls.Get(context);
            form = new Form();
            form.Text = Title.Get(context);
            form.ControlBox = false;
            var tlp = new TableLayoutPanel();
            form.Controls.Add(tlp);

            tlp.AutoSize = true;
            tlp.ColumnCount = 2;
            tlp.RowCount = controls.Count;
            tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            tlp.GrowStyle = TableLayoutPanelGrowStyle.AddRows;

            formControls = new List<Control>(controls.Count);

            for (int i = 0; i < controls.Count; i++)
            {
                var kvp = controls.ElementAt(i);
                tlp.Controls.Add(new Label() { Text = kvp.Key, TextAlign = System.Drawing.ContentAlignment.MiddleCenter }, 0, i);
                var ctrl = CreateControl(kvp.Value);
                ctrl.Name = kvp.Key;
                tlp.Controls.Add(ctrl, 1, i);
                formControls.Add(ctrl);
            }
            var btn = new Button();
            btn.Text = "Submit";
            btn.Click += Btn_Click;
            tlp.Controls.Add(btn, 1, tlp.RowCount);
            form.AcceptButton = btn;
            form.ShowDialog();

            InputResults.Set(context, results);
        }

        private void Btn_Click(object sender, EventArgs e)
        {
            results = new Dictionary<string, string>(formControls.Count);
            foreach (var cntrl in formControls)
            {
                results.Add(cntrl.Name, cntrl.Text);
            }
            form.Close();
        }

        private Control CreateControl(string[] options)
        {
            switch (options.Length)
            {
                case 0:
                    return new TextBox();
                case 1:
                    return new TextBox() { Text = options[0] };
                default:
                    var cmb = new ComboBox();
                    foreach (var option in options)
                    {
                        cmb.Items.Add(option);
                    }
                    return cmb;
            }
        }
    }
}

Making it not look like Baby’s First Winform should be pretty straightforward enough to edit.
As noted, the code could be better (it’s 1 am here… just needed something to space out with) and the form is definitely not the prettiest, but it works.

For an input like this:

New Dictionary(Of String, String()) From { _
{ "Text field without default", New String() {} }, _
{ "Text field with default", New String() {"abc"} }, _
{ "Combo box", New String() { "1st value", "2nd value", "3rd value" } }, _
{ "Another combo box", New String() { "a value", "the value", "some value" } }
}

It will make a form like this (combo boxes work):
image

After filling:
image

Which the results from will be stored in the output Dictionary<string, string>.
A foreach KeyValuePair<string, string> (which the Dictionary is implicitly convertible to) -> writeline(item.Key + ": " + item.Value) produces:
image

(Note: tested only in VS, but should work in UiPath without modifications)

Hope it will be useful for someone.

Good night :wink:

14 Likes

Adrzej,

should I use the code inside the invoke code?

this is the error I’m getting…

Invoke code : Error compiling code
error BC36008: ‘Using’ must end with a matching ‘End Using’. At line 1
error BC30112: ‘System’ is a namespace and cannot be used as an expression. At line 1


then I tried to import the namespaces on uipath, but the CodeActivity is giving me this error :
‘CodeActivity’ is a type and cannot be used as an expression. At line 1

:slight_smile:

No, compile it as a .dll and pack and import in .nupkg.

1 Like

ohhh, cool, great job btw… and the form design its retro I would say… heheh :sunglasses:

1 Like

It is. It will take some time though.

1 Like

Never got to try this, but great effort @andrzej.kniola

@andrzey.kniola, that looks and I’ll try it if/when I graduate :sunglasses: I have had a little luck with AutoHotkey, see the animation below. I’m going to try to mash up an AHK version of the form you posted, I’ll edit this when I have it done. As soon as I can figure out a way to post the code from the animation so it’ll work for somebody downloading, I will. Right now it relies on a few things integral to my machine, which I am working around.

shopbot

EDIT: Well, that didn’t take too long for a quick and dirty AHK form:

After loading;

Here’s the code (script and icon):

burque505-AHKform.zip (5.0 KB)

2 Likes

@andrzej.kniola Can you please show that how to make a design of this form?

Hi! I’ve tried to create the nupkg as described and should be ok. But now in which way have you called the form box for allowing the user to fill it? Can you attach a screen with the activity? Thanks in advance.

How can i do this with UiPath?

Regards
J.

For anyone who is looking for this after me: release 2018.3 fixes this with Custom Input which allows you to create HTML forms and retrieve the values entered.
https://activities.uipath.com/docs/custom-input-activity

1 Like

LOL! I was searching for this solution and found this thread. I wanted to thank the guy finding it in the 2018.3 release, only to find out it was me :sweat_smile:

2 Likes