Autofill text box based on results in a repeating table field - InfoPath Dev
in

InfoPath Dev

Autofill text box based on results in a repeating table field

Last post 09-06-2010 06:41 PM by Potemkine. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 08-29-2010 10:26 PM

    • Grinch
    • Not Ranked
    • Joined on 08-29-2010
    • Posts 7

    Autofill text box based on results in a repeating table field

    Hi

    I am new to Infopath and am not a programmer, we are using Infopath 2003 and I have created a change management form for our company to use.

    I am struggling with populating a textbox which is outside the repeating table with the results from the third field within the repeating table.

    I have a drop down list box and 2 text fields within the repeating table which gets its data from a secondary source (sharepoint list).

    The third field populates with either gold, silver, or bronze dependant on what is selected from the drop down list.

    I want to check each row where the field containing gold, silver, or bronze is and if there is a gold within any row, set the text box to "High", if the highest is silver then set it to "Medium", etc.

    Is there any way to do this, if possible without code. If not I will give code a go?

    thanks for your help

    Anthony

  • 08-30-2010 08:09 AM In reply to

    Re: Autofill text box based on results in a repeating table field

    Hi Anthony, a way to do that without code is to add rules based on the parent group of your drop down field. You can create a new group and move your repeating field in it, if it's not already here. You set a condition to your first rule like: if (ParentOfField1) contain Copper, set a field value to field 3 "normal",  you add another rule for silver, gold, etc.... 

  • 08-30-2010 05:45 PM In reply to

    • Grinch
    • Not Ranked
    • Joined on 08-29-2010
    • Posts 7

    Re: Autofill text box based on results in a repeating table field

    Hi

     

    Thanks for the prompt reply. I am not sure I understand what to do, are you able to provide an example.

    The drop down list box is within a group by default 

    Top Group = Required_Approvers, then there is another group sitting under the first group = Approvers.

     Then there are 3 fields within the second group. I pull information into these fields from a Sharpoint list using a data connection

    1st = system (dropdown list)

    2nd = approver (read only textbox)

    3rd = critical (read only textbox)

    Elsewhere on the form (outside this group) I have a read only textbox called system_importance.

    I want to look through the rows in "critical" and the highest value present such as Gold, or Silver, or Bronze (no matter on which row) gets translated to High, Medium, or Low in system_importance.

    I can get it to work by adding rules in the "critical" field but when ever I add a row it only looks at the new row and puts the value in for that row. There isn't any logic to compare the rows and see what the highest value is.

     Sorry if I am not clear as I am not used to any of this.

     thanks again

     Anthony

  • 08-30-2010 06:43 PM In reply to

    Re: Autofill text box based on results in a repeating table field

     Ok, I attach an example, it can help you to design your form.

  • 08-30-2010 09:10 PM In reply to

    • Grinch
    • Not Ranked
    • Joined on 08-29-2010
    • Posts 7

    Re: Autofill text box based on results in a repeating table field

    Hi

    Sorry to be a pain, are you able to save it as Infopath 2003

    many thanks

    Anthony

  • 08-31-2010 09:48 PM In reply to

    • Grinch
    • Not Ranked
    • Joined on 08-29-2010
    • Posts 7

    Re: Autofill text box based on results in a repeating table field

    Hi I got it working, I found someone with a later version of Infopath and applied the rules as you put them in your example.

    THANKYOU

    I have a further question - If someone was to delete a row how can I refresh the Textbox so it looks at the values left rather than what was initially set.

    At the moment if I was to have a High entry then I remove the row with that system it does not adjust the textbox.

    thanks again

    Anthony

  • 09-05-2010 05:24 AM In reply to

    Re: Autofill text box based on results in a repeating table field

     Hi Anthony, it seems that rules doesn't apply if we delete/add a new row. I think you need to add some codes. Just ask me if you need some help.

  • 09-05-2010 07:05 PM In reply to

    • Grinch
    • Not Ranked
    • Joined on 08-29-2010
    • Posts 7

    Re: Autofill text box based on results in a repeating table field

    Hi

    I would appreciate some help as I do not know how to do code. I am using Infopath 2003

    thanks

    Anthony

  • 09-06-2010 06:32 AM In reply to

    Re: Autofill text box based on results in a repeating table field

     Hi Anthony, I suggest you to use C#  2003 on "form option" go to "programming" and select C# (compatible 2003). After that you have to add an event handler on the parent node  of your repeating node in my template it's"my:r"(right click on the field on the main data source, select "programming" and On after change event).It's imprtant to use the parent and not the repeating table itself because the delete event will be fired on the parent and not on the repeating table.

    you can use this code:

    string value = thisXDocument.DOM.selectSingleNode("/my:myFields/my:r").xml;
                if(value.Contains("Bronze"))
                    thisXDocument.DOM.selectSingleNode("/my:myFields/my:t/my:t2").text="Low";
                if(value.Contains("Silver"))
                    thisXDocument.DOM.selectSingleNode("/my:myFields/my:t/my:t2").text="Normal";
                if(value.Contains("Gold"))
                    thisXDocument.DOM.selectSingleNode("c").text = "High";

     You have to replace "/my:myFields/my:r" by your repeating table Xpath (To copy Xpath you can make a right click on your field and select "copy xpath")

    and "/my:myFields/my:r" by your other field Xpath

  • 09-06-2010 05:21 PM In reply to

    • Grinch
    • Not Ranked
    • Joined on 08-29-2010
    • Posts 7

    Re: Autofill text box based on results in a repeating table field

    Hi

    C# is not an option, only VBScript and JScript are showing.

    Do I need to install someting on my PC?

    thanks

    Anthony

     

  • 09-06-2010 06:41 PM In reply to

    Re: Autofill text box based on results in a repeating table field

     Hi, I convert it to j-Script:

    var value = XDocument.DOM.selectSingleNode("/my:myFields/my:r").xml

    if(value.indexOf("Bronze")!=-1)

    XDocument.DOM.selectSingleNode("/my:myFields/my:t/my:t2").text="Low";

    if(value.indexOf("Silver")!=-1)

    XDocument.DOM.selectSingleNode("/my:myFields/my:t/my:t2").text="Normal";

    if(value.indexOf("Gold")!=-1)

    XDocument.DOM.selectSingleNode("/my:myFields/my:t/my:t2").text = "High";

Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.