Drop-Down for Web-Service Results

  • 85 Views
  • Last Post 06 March 2018
  • Topic Is Solved
zingix posted this 19 February 2018

Dear Community,

To verify the recognized field data I use a REST web service which is connected to a database containing all information possible in the forms. Using this web service, I can lookup details about people in the company (e. g. first name, last name etc.).

The web service implements various technologies to find the best match to the recognized data. But: sometimes, there are multiple results which might get a similar score or the score of all results is very low.

For this case I want the Validation Guy to selected the best matching element from a drop down list. I am aware of the "Suggest" property which some form fields support. What I want to have is a drop down containing the full name and some details which are - if an entry is selected - copied to the recognized form fields (instead of having a drop down for each individual form field ...).

Any suggestions?

Regards,
Michael

Order By: Standard | Newest | Votes
AlexeyEfremov posted this 06 March 2018

Hello,

Here is the example from one of my projects (in C#). You can suggest value in every field you need as the values for all fields in the fixed order separated by one specific symbol (for example long dash "—")  like this:

string suggestion = fieldValue1  + " — "  fieldValue2  + " — " fieldValue3  + " — " fieldValue4;

Context.Field("field1").Suggest(suggestion);

Context.Field("field2").Suggest(suggestion);

Context.Field("field3").Suggest(suggestion);

Context.Field("field4").Suggest(suggestion);

 

Then in another rule (or the same rule, this does not matter) 

 

            try

            {

                string input = "";

                if (Context.Field("field1").Text.Contains('—'))

                {

                    input = Context.Field("field1").Text;

                }

                if (Context.Field("field2").Text.Contains('—'))

                {

                    input = Context.Field("field2").Text;

                }

                if (Context.Field("field3").Text.Contains('—'))

                {

                    input = Context.Field("field3").Text;

                }

                if (Context.Field("field4").Text.Contains('—'))

                {

                    input = Context.Field("field4").Text;

                }

                if (input != "")

                {

                    System.Text.RegularExpressions.Regex reg = new Regex(@"(?<field1>.*) — (?<field2>.*) — (?<field3>.*) — (?<field4>.*)");

                    System.Text.RegularExpressions.Match filesMatch = reg.Match(input);

                    Context.Field("field1").Text = filesMatch.Groups["field1"].Value;

                    Context.Field("field2").Text = filesMatch.Groups["field2"].Value;

                    Context.Field("field3").Text = filesMatch.Groups["field3"].Value;

                    Context.Field("field4").Text = filesMatch.Groups["field4"].Value;

                    Context.Field("field1").IsVerified = true;

                     Context.Field("field2").IsVerified = true;

                     Context.Field("field3").IsVerified = true;

                     Context.Field("field4").IsVerified = true;

                    Context.CheckSucceeded = true;

                }

            }

            catch (Exception ex)

            {

                Context.CheckSucceeded = false;

                Context.ErrorMessage = ex.Message;

            }

This way, the moment  the Validation Guy chooses the variant from the suggested list, the suggestion will be parsed and inserted in all the fields needed.

Hope this helps.

 

 

zingix posted this 06 March 2018

Hi Alexey,

Thanks for your answer. This is actually quite clever - inserting special characters as field values which are then processed by another rule. Thanks for the hint, brilliant.

Regards,
Michael

Close