Creating Repeating Section At Run Time - InfoPath Dev
in

InfoPath Dev

Creating Repeating Section At Run Time

Last post 09-05-2005 04:58 AM by Coita Thierry. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 04-29-2005 10:34 AM

    • Idisis
    • Not Ranked
    • Joined on 04-28-2005
    • Posts 5

    Creating Repeating Section At Run Time

    Hello All,

    I am still very new to InfoPath so please bear with me :)

    What i am trying to do is create a dynamic section to the form that is read from a sharepoint site. What this dynamic section needs to do is display within a layout table a checkbox, textbox, an optional section, and inside that optional section another text box. It looks something like this:

    |----------------------------------|
    | checkbox | Textbox #1 |
    | |-----------------------|
    | | Textbox #2 <---- Optional section
    |----------------------------------|

    The kicker here is I need this to be able to repeat based on values gathered from the share point site. I have the repeating Section surrounding the above items. So on my form i have the repeating Section, inside that section is the layout table above, insude that table is the checkbox in column 1, Textbox and optional section in column 2 and inside the optional section is another textbox.

    On my sharepoint site I have a list created called Test Procedures. Within this list I have a field called Procedure, Component, and version. What I want to do is get that list of test procedures from the sharepoint site and then create a new instance of the above for each procedure within the list and display the Procedure field in Textbox#1.

    My second goal out of all this is to filter the Test Procedures list to only include Components and Versions that the user has selected from a dropdown list (for the case of examples just assume that Component = 'Test' and Version = '1.00').

    For Example: The user has selected Test from the components dropdown and then selected version 1.00. This will display the above section and it should now display all the Procedures associated to component Test and version 1.00. This will cause the repeating section to produce an instance of the above for each procedure in my sharepoint list.

    To read from the secondary datasource I have tried the following code with no success:
    XDocument.DataObjects("Test Procedures").DOM

    To insert additional section into a repeating section at run time I have tried the following code with no success:
    XDocument.View.ExecuteAction("xCollection::insert", "comp_repeat"); //com_repeat is the name of my repeating section

    Thanks in advance,
    Ryan

    Note: I am using the SP1 version of InfoPath
  • 04-30-2005 09:52 AM In reply to

    Re: Creating Repeating Section At Run Time

    Hi Idisis,
    When you are getting DOM, you are using "DataObjects" as a method where as "DataObjects" is a property(variable) so your first statement should be
    "XDocument.DataObjects["Test Procedures"].DOM"
    Also please check whether you have created your dataconnection to the sharepointlist properly.

    NOTE: From here on i will use c# Code because I am not familiar with "Script".

    For inserting repeating section
    Probably it will work the way you have done it but I dont do the way you do, I do it with the code.
    Steps I follow if i want to insert "Field" into a node are
    1. Take XML for the section as a string
    string xmlString = "<Field1/>"
    2. Create an IXMLDOMDocument out of it.
    IXMLDOMDocument domXMLNode = (IXMLDOMDocument)thisXDocument.CreateDOM();
    3. Load that xml into above dom
    domXMLNode.async = false;
    domXMLNode.loadXML(xmlString);
    4. Get the node in which you want to insert this new node
    IXMLDOMNode oParentNode = getParentNode();
    5. Append your new node to the parentnode.
    oParentNode.appendChild(domXMLNode.documentElement);

    You can loop "oParentNode.appendChild(domXMLNode.documentElement)" statement and insert multiple nodes(Repeated nodes).

    Hope this Helps!

    Agni
    InfoPathDev India
  • 09-05-2005 12:01 AM In reply to

    Re: Creating Repeating Section At Run Time

    Hi Agni,

    Good post but I don't understand one things:

    quote:
    4. Get the node in which you want to insert this new node
    IXMLDOMNode oParentNode = getParentNode();


    What is this method getParentNode() ?

    VS say that : getParentNode() the name doesn't exist in the class or in the namespace of the form!

    So what I have to do for that work?

    In the first part of answer you speak about:

    quote:
    When you are getting DOM, you are using "DataObjects" as a method where as "DataObjects" is a property(variable) so your first statement should be
    "XDocument.DataObjects["Test Procedures"].DOM"
    Also please check whether you have created your dataconnection to the sharepointlist properly.


    Is this important for the answer you are given under because I don't fully understand what you try to explain?

    Thanks for your help!

    ++

    Thierry


    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 09-05-2005 01:05 AM In reply to

    Re: Creating Repeating Section At Run Time

    Ok I have understand what is getParentNode()
    it's a selectsinglenode of the reapeating section!

    But now I have an error in the last line:

    oParentNode.appendChild(domXMLNode.documentElement);

    that make me the following error:
    quote:
    System.Runtime.InteropServices.COMException
    Element 'Person' is unexpected according to content model of parent element 'Person'.
    at Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNode.appendChild(IXMLDOMNode newChild)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.DOMNodeWrapper.appendChild(IXMLDOMNode newChild)
    at Microsoft.Office.Interop.InfoPath.SemiTrust.DOMNodeWrapper.appendChild(IXMLDOMNode newChild)
    at Req2.Req2.RemovePers_OnClick(DocActionEvent e) in c:\documents and settings\tc\bureau\st gallen\visual studio projects\req2\formcode.cs:line 128
    at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)



    my code is:

    IXMLDOMNode loesch= thisXDocument.DOM.selectSingleNode("/CaseList/Case/AV/AVel/PersBisher/Person[Personalien/PersDaten = ../../../AVel/PersNeuMut/PersListe]");
    IXMLDOMDocument domXMLNode = (IXMLDOMDocument)thisXDocument.CreateDOM();
    domXMLNode.async = false;
    domXMLNode.loadXML(loesch.xml);
    IXMLDOMNode oParentNode = thisXDocument.DOM.selectSingleNode("/CaseList/Case/AV/AVel/PersNeuMut/Person");
    oParentNode.appendChild(domXMLNode.documentElement);


    As you can see the Xmlnode is take in a node of the primary datasource and she is copy in another one so why that make this kind of error?

    Thanks for your reply!

    ++

    Thierry

    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 09-05-2005 01:12 AM In reply to

    Re: Creating Repeating Section At Run Time

    If you see "loesch" is the person node and "oParentNode" is also person node, and your schema does not allow this.

    Agni
    InfoPath Dev India
  • 09-05-2005 02:50 AM In reply to

    Re: Creating Repeating Section At Run Time

    Hi,

    Thanks for your answer

    I'm not sure to good understand but why I can say:

    Person is a type (in the schema PersType) and you can find it in PersNeuMut and in PersBisher:

    <?xml version="1.0" encoding="UTF-8"?>
    ...
    <AVel>
    <PersBisher>
    <PersListe/>
    <Person Aenderung="" Ein="6" loe="" mut="" seq="" toCheck="" valid="">
    <RefCancel Ein="" seq=""/>
    <Personalien valid="">
    <Name Prefix=""/>
    <Vorname/>
    <Heimat BFS="" Land=""/>
    <WohnOrt PLZ="" Land=""/>
    <PersDaten/>
    </Personalien>
    <Funktion>
    <Fkt FunkNr="" valid="">
    <func/>
    <kurz/>
    </Fkt>
    </Funktion>
    <Signature>
    <ZB ZartNr="" ExtraNr="" valid="">
    <sign/>
    <signKurz/>
    <extra/>
    <extraKurz/>
    </ZB>
    </Signature>
    <ScannUnterschrift/>
    </Person>
    </PersBisher>
    ...


    and PersNeuMut:

    <?xml version="1.0" encoding="UTF-8"?>
    ...
    <AVel>
    <PersNeuMut>
    <PersListe/>
    <Person Aenderung="" Ein="6" loe="" mut="" seq="" toCheck="" valid="">
    <RefCancel Ein="" seq=""/>
    <Personalien valid="">
    <Name Prefix=""/>
    <Vorname/>
    <Heimat BFS="" Land=""/>
    <WohnOrt PLZ="" Land=""/>
    <PersDaten/>
    </Personalien>
    <Funktion>
    <Fkt FunkNr="" valid="">
    <func/>
    <kurz/>
    </Fkt>
    </Funktion>
    <Signature>
    <ZB ZartNr="" ExtraNr="" valid="">
    <sign/>
    <signKurz/>
    <extra/>
    <extraKurz/>
    </ZB>
    </Signature>
    <ScannUnterschrift/>
    </Person>
    </PersNeuMut>
    ...


    The only difference is that there are not in the same AVel element!

    Is there a way to copy one in the other?

    Thanks a lot!

    ++

    Thierry

    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 09-05-2005 04:58 AM In reply to

    Re: Creating Repeating Section At Run Time

    ok I have understand now (after have read 100 times your answer)

    The answer is:

    IXMLDOMNode loesch= thisXDocument.DOM.selectSingleNode("/CaseList/Case/AV/AVel/PersBisher/Person[Personalien/PersDaten = ../../../AVel/PersNeuMut/PersListe]");
    IXMLDOMDocument domXMLNode = (IXMLDOMDocument)thisXDocument.CreateDOM();
    domXMLNode.async = false;
    domXMLNode.loadXML(loesch.xml);
    IXMLDOMNode oParentNode = thisXDocument.DOM.selectSingleNode("/CaseList/Case/AV/AVel/PersNeuMut");
    oParentNode.appendChild(domXMLNode.documentElement);


    Thanks a lot for your help Agni!

    ++

    Thierry

    Every moment hesitated is a moment gone for life!!! Think about it
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.