Delivery of value between form A to form B - InfoPath Dev
in

InfoPath Dev

Delivery of value between form A to form B

Last post 09-12-2008 12:42 PM by BuildPro Guru. 34 replies.
Page 1 of 3 (35 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 02-21-2007 07:54 AM

    Delivery of value between form A to form B

    Hello,

    I have the following problem:

    I would like the value x, which is in a drop down list in form B transferred into a text field from form A.
    From form A I arrive over a Button form B.

    How does that function?

    I hope myself can someone help.

    Greeting Matthias
  • 02-21-2007 02:19 PM In reply to

    Re: Delivery of value between form A to form B

    There is an XDocuments collection. It gives you access to the DOM for every open form, allowing you to copy the required value.
  • 02-21-2007 11:41 PM In reply to

    Re: Delivery of value between form A to form B

    Thanks for the information.
    I already read some in books and on the Microsoft web pages about XDocument and DOM (document Object Model). Unfortunately I am absolute a newbie with InfoPath and I'm not yet very good in programming.
    Therefore I posted my problem in this forum.

    Perhaps you could give me a small example, how I could realize such a delivery.

    Thank you for your help.

    Greeting Matthias
  • 02-22-2007 09:29 AM In reply to

    Re: Delivery of value between form A to form B

    This is from the Microsoft InfoPath 2003 help:

    quote:
    To access an XDocument object contained in the XDocuments collection, you can pass the positional index or the location path to the Item method:

    var objXDoc;

    objXDoc = Application.XDocuments(0);
    // or...
    objXDoc = Application.XDocuments("C:\\MyForm.xml");

    So, for example, XDocuments(0) is your current form. If you know there are only two forms open, then the other form would be XDocuments(1) -- however, I would never rely on the user only having a cerain number of forms open.

    Once you have your objXDoc set and pointing to the other form, you would get and set field values just the same as you would in your own current form.

    Current form:

    XDocument.DOM.selectSingleNode("/XPathToNode").text = "Some Value";

    Other form:

    var objXDoc = Application.XDocuments(1);
    objXDoc.DOM.selectSingleNode("/XPathToNodeInOtherForm").text = "Some Value";
  • 02-23-2007 02:33 AM In reply to

    Re: Delivery of value between form A to form B

    Thanks for your help.

    I hope I can do it now with your information.

    Thanks.
  • 02-23-2007 05:27 AM In reply to

    Re: Delivery of value between form A to form B

    Hello,

    I do not how the function works.
    Now the following code I used in my form B:
    function XDocument::OnLoad(eventObj)
    {
    var objXDoc = Application.XDocuments(1);
    objXDoc.DOM.selectSingleNode("//my:schulung").text = "test";
    }

    The connection to form A is missing, or?
    In form A the drop down listis called bezeichnungderveranstaltung.
    In form B the text box is called schulung.

    Where can I specify now that exactly the value, which was selected in the drop down list also in the text box in form B is written?
    In addition I must also say, which value from which form (here A) I deliver into the other form (here B) so that the value of the drop down list (which is in form A) is also in the textbos (whisch is in form B).
    Only 2 forms are opened (A and B).

    Sorry of my asking, but I believe I think too complicated.

    Greeting Matthias

    P.S. I hope you understand my english.
  • 02-23-2007 09:27 AM In reply to

    Re: Delivery of value between form A to form B

    When do you open FormB? Is it after the drop-down value in FormA is already selected? Or is it before?

    FormB opens AFTER formA drop-down value selected:

    Here you can use the OnLoad code like you have. But you need to be selecting the FormA field, which you've stated is "bezeichnungderveranstaltung". In your code above, you are trying to select the FormB field "schulung" from FormA--where it doesn't exist. If you want it to contain the value of the drop-down in FormA, then you would need code like:

    var objXDoc = Application.XDocuments(1);
    var ddValue = objXDoc.DOM.selectSingleNode("//my:bezeichnungderveranstaltung").text;
    XDocument.DOM.selectSingleNode("//my:schulung").text = ddValue;


    FormB opens BEFORE formA drop-down value selected:

    In this situation you would want to have some OnAfterChange code which copies the new selected value to FormB. It would be something like this:

    var ddValue = e.Site.text;
    var objXDoc = Application.XDocuments(1);
    objXDoc.DOM.selectSingleNode("//my:schulung").text = ddValue;


    - - - - -

    Now I might have a few mistakes in the code, but it should give you an idea of how this would work depending on when FormB was opened compared to FormA.
  • 02-24-2007 03:56 AM In reply to

    Re: Delivery of value between form A to form B

    Thanks a lot for your time that you spend on my problem.

    On monday I can implement and test your Information.

    Thanks so much for now!
  • 02-26-2007 01:19 AM In reply to

    Re: Delivery of value between form A to form B

    Good morning

    I have unfortunately already again a problem.
    Your code I think I have understood so far like the individual steps.

    The form B is only called if in the drop down list were already selected a value. I made it also in such a way that someone first stores the form A and then the new form opens. Form A won't be closed.

    If I merge the following code I get the following error:
    >> Reference to a not defined namespace prefix: ' my '.

    XDocument.DOM.setProperty("SelectionNamespaces", ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-02-21T08:11:30" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" ');
    function XDocument::OnLoad(eventObj)
    {
    var objXDoc = Application.XDocuments(0);
    var ddValue = objXDoc.DOM.selectSingleNode("//my:bezeichnungderveranstaltung").text;
    XDocument.DOM.selectSingleNode("//my:schulung").text = ddValue;
    }

    However I refer in this code to the XDocument(0).
    The fields and groups are kind-moderately proven with ' my '. In it I changed also nothing.
    I have already try the fields with ' dfs ' to address, however it come the same error.

    If I refer to the XDocument(1), I get the following error:
    >> The index value lies outside of the valid range.
    >> Unknown index.

    What could this lie?
    How could I avoid these errors or which I make wrongly?

    Greeting Matthias

    P.S. You can contact me also per e-Mail: MatthiasXL(at)web.de
  • 02-26-2007 11:10 AM In reply to

    Re: Delivery of value between form A to form B

    You might be trying to map in FormA namespaces into FormB or the other way around. Make sure that when you set the selectionnamespaces, that you are setting the correct set of namespaces from the correct form.
  • 02-27-2007 02:12 AM In reply to

    Re: Delivery of value between form A to form B

    I'm it already again.
    Now I have it exists the "namespace error" anymore.

    However now another error comes:
    'XDocument.DOM.selectSingleNode(...)' is zero or no object

    This error arises in the last code line.
    I do not think that the value is zero, because I filled out the fields in form A with values and stored the form.
    I tried it also like this: A button with a "OnClick" in form B integrated and there the code implemented.
    There I get the error: Object necessarily!

    I didn't programmed with JScript befor and do not know the syntax.

    I would be pleased, if you can help me with my problem.

    Greeting and thanks in advance
    Matthias
  • 02-27-2007 10:01 AM In reply to

    Re: Delivery of value between form A to form B

    In your code you have:

    var objXDoc = Application.XDocuments(0);
    var ddValue = objXDoc.DOM.selectSingleNode("//my:bezeichnungderveranstaltung").text;
    XDocument.DOM.selectSingleNode("//my:schulung").text = ddValue;

    Know that Application.XDocuments(0) is the same thing as XDocument. 0 is always the current form. If you want to get the other form's XDocument, you will need to use Application.XDocuments(1).
  • 02-27-2007 11:38 PM In reply to

    Re: Delivery of value between form A to form B

    Hello

    so far I also understood that.

    If I make Application.XDocuments(1) come this error:
    >> The index value lies outside of the valid range.
    >> Invalid index.

    I call on the code in form B (with OnLoad) and say that he should transfer the value from "bezeichnungderveranstaltung" (of form A) into text field "schulung".
    Nevertheless the code should function, if I understood everything correctly.

    Or do I make a thought error?

    Greeting Matthias
  • 02-28-2007 07:37 AM In reply to

    Re: Delivery of value between form A to form B

    I now already tried most diverse things.
    Whether it is a data transfer from a text field (from form A) into a text field (in form B) or by OnClick event load the value from form A (is opened) into form B.

    I am with at the end my latin and get soon the crisis. It is certainly only a small error which I still make, but I don't know what. Which I make, an error comes again and again.

    The form world, in which both forms are should be integrated, functions very well. Also both forms work perfectly.
    Only these small value delivery doesn't work.

    Can the problem be that I use InfoPath 2007 and not InfoPath 2003?
  • 03-02-2007 09:22 AM In reply to

    Re: Delivery of value between form A to form B

    Which are you using right now? InfoPath 2003 or 2007?

    If you are using 2007, are you using the IP03 OM or the IP07 OM? Because that makes a difference.

    Getting the "index value lies outside of the valid range" error indicates that there is not a second form open (i.e. XDocuments(0) is always valid, but XDocuments(1) is invalid because there is no second form). For this you can check the value of the Application.XDocuments.Count property to make sure it is greater than 1.

    If you are using the IP07 OM then there is no XDocuments collection under Application... instead there is a XmlForm collection, which also has a Count property that you can check. I've not used this collection yet and don't know how it works.
Page 1 of 3 (35 items) 1 2 3 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.