Delivery of value between form A to form B - InfoPath Dev Sign in | Join | Help in Newbie Questions InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » Newbie Questions » Delivery of value between form A to form B Delivery of value between form A to form B Last post 09-12-2008 12:42 PM by BuildPro Guru. 34 replies. Page 2 of 3 (35 items) < Previous 1 2 3 Next > Sort Posts: Oldest to newest Newest to oldest Previous Next 03-02-2007 01:48 PM In reply to Smeets Joined on 02-21-2007 Posts 24 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact I use IP 2007.Is there another possibility which I can deliver a value from form A to Form B? Everything works, only this "little" value delivery doesn't work.The Code witch you gave me in a post before works only with die IP 2003 ?I have asked a lot people that I know, but nobody could help me, so my hope lies on you. 03-03-2007 02:13 PM In reply to Greg Collins Joined on 08-07-2006 Posts 2,126 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact IP07 allows you to develop using the IP03 OM or the new IP07 OM.Some clues to know which you are using:IP03 OM uses objects like thisXDocument, IXMLDOMNode, IXLMDOMDocumentIP03 OM has events such as OnAfterChange, OnBeforeChange, OnLoadIP07 OM uses objects like XmlForm, XmlNode, XmlDocumentIP07 OM has events such as Changed, Changing, LoadingIf you recognize that you are using the IP03 OM, then Application.XDocuments(1) is the correct syntax to be using. If you recognize that you are using the IP07 OM, then I don't have enough knowledge yet to be able to help you, but would suggest looking into the XmlForm collection as the most likely place to start. Please Visit:BraintroveGreg's Paintings 03-04-2007 10:37 AM In reply to Smeets Joined on 02-21-2007 Posts 24 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact OK. Thanks for this Information.I only know, that I work with InfoPath 2007.For what does the OM stand for?So I have to look if I can use die IP03 OM.Thanks a lot. Do you knwo someone how can help me, if I have problems with dei IP07? 03-05-2007 03:51 AM In reply to Smeets Joined on 02-21-2007 Posts 24 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact Hello, if I understood that correctly, then I can use IP 2007 and it works also with the IP03 object model (I think that OM stands for object model). Can I made these attitude afterwards still make or must I have this before I sketch the form? If yes, where can I change this attitude? I have only read that one this equal to specify at the beginning with which one of the OM's I would like to work.It would be now very time-consuming to provide the forms again. I thank you for your support and assistance concerning my questions.GreetingsMatthias 03-05-2007 07:52 AM In reply to Smeets Joined on 02-21-2007 Posts 24 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact Now I converted the forms so that I can open and work also in the IP 2003 and this should now theoretical function with the code that I had posted before. Unfortunately the value is however not taken over. Also no error comes as I open form B. So I don't know what problem I have. However a value is located in the field in form A, since this field is filled automatically and I can see that.But what can I know do, that everything works correctly? 03-05-2007 09:46 AM In reply to Greg Collins Joined on 08-07-2006 Posts 2,126 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact Yes, OM stands for Object Model. If you were able to successfully save your form to work with IP03, open it in IP03 and still run it, then yes, you were using the IP03 OM. As I look back in the thread, I noticed that I should have seen that you were using the IP03 OM, but you are using JScript and not C#. Sorry--my mistake. I should have seen that. So-- you are using InfoPath 2003, with JScript. This means that you Application.XDocuments is the right collection to be working with. What I want you to do is to add the following lines of code and report back what it provides in the alert box: XDocument.UI.Alert(Application.XDocuments.Count); var x = Application.XDocuments(0).DOM; XDocument.UI.Alert(x.xml); x = Application.XDocuments(1).DOM; XDocument.UI.Alert(x.xml); NOTE: This code CANNOT be in the OnLoad event handler or it will not work correctly. The XDocument in not added to the collection until AFTER the onload has completed. Please Visit:BraintroveGreg's Paintings 03-05-2007 09:49 AM In reply to Greg Collins Joined on 08-07-2006 Posts 2,126 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact Sorry - I had told you earlier in this thread that you can use this in OnLoad, but I've just verified that it does not work in OnLoad... it has to be done elsewhere--which might take some figuring out on your part as to where it should occur (if you were trying to do it in OnLoad). An OnClick event is just fine, or perhaps an OnAfterChange event. Please Visit:BraintroveGreg's Paintings 03-06-2007 12:03 AM In reply to Smeets Joined on 02-21-2007 Posts 24 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact I implemented the code with the alert box. I open form A, put in my values, go by button-click to form B (where your code is implemented) an form A is already open, I get in the first alert box the "1" as output. In the secound alert box I get the infos of the xml-file: e.g. <my:bezeichnungderverantsaltung>SchulungTest 5</my:bezeichnungderveranstaltung> an all the other fields which I put an value into will be shown in this alert box. After that I get an error in the secound part of your code: x = Application.XDocuments(1).DOM; >> index value lies outside of the valid range 03-06-2007 11:45 AM In reply to Greg Collins Joined on 08-07-2006 Posts 2,126 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact Sorry, I have to ask this... but did you make sure that the code is NOT in the onload event handler? The new XDocument is not added to the XDocuments collection until after onload has finished. Since you are only getting 1 for the count, InfoPath has not recognized the second form being open yet. That is why the XDocuments(1) fails. The count should be 2. Please Visit:BraintroveGreg's Paintings 03-06-2007 12:01 PM In reply to Smeets Joined on 02-21-2007 Posts 24 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact The Code is not in the OnLoad-Function, because I have commentated the OnLoad-Function. Whit the button I save form A and with an other butten I open a new Form. In this case form B. Everything functions without any code because I use rules in the forms. So die only code I need is in Form B the onload-function to get the value of form A. 03-07-2007 10:24 AM In reply to Greg Collins Joined on 08-07-2006 Posts 2,126 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact I just ran some tests and it looks like I gave some misleading information earlier. XDocuments(0) is NOT always the current document, but rather the first document open. In your case though, since Form A was open first, that would indeed be XDocuments(0). However, for Form B, you don't want to use XDocuments(1) as this will point you back to Form B. So Form A is already open. This is XDocuments(0). Button on Form A opens Form B. Form A is still XDocuments(0) in BOTH forms, and Form B is XDocuments(1) in BOTH forms. Sorry for the misinformation. Maybe this will help. Remember though, Form B *CANNOT* use the OnLoad function to get the value of Form A. Another option, since you said that Form B is opened by clicking a button on Form A, if you are using code (and not rules) to open Form B, then that function has a return value which is the XDocument to Form B. You can use this XDocument return value to set the field value in Form B. For example: var xdFormB = MY_CODE_THAT_OPENS_FORM_B(); // Set namespaces here. var sFormAFieldValue = XDocument.DOM.selectSingleNode("/my:myFields/my:FormAField").text; xdFormB.DOM.selectSingleNode("/my:myFields/my:FormBField).text = sFormAFieldValue; Please Visit:BraintroveGreg's Paintings 03-08-2007 12:25 AM In reply to Smeets Joined on 02-21-2007 Posts 24 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact Thanks for this Information. It could be also because of my English, which I had sometimes misleadingly expressed myself. It soundsto very simple to do your tip, but my prgamming knowledge ist not very good, anyhow in JScript. If I understood you correctly, I have to implement your example in form A, where I open form B with die MY_CODE_THAT_OPENS_FORM_B()-Function. In every other forms I use rules to open forms, to close forms and fill the fields in this forms. I searched in books and the internet if there is a help how to open a new form with an button-click. But haven't found realy good informations. For example I looked at the following page: http://www.infopathdev.com/howto/bugs/default.aspx?i=9fc31c95201f44a1938ba8d9cf47d5e5 But I don't know how to use this code. Form B is saved as template.xsn on a server. (like http://sharepoint.company.com/name/Forms/template.xsn) I don't know to combine this code-lines. I have no fixed *.xml-file an the form whitch should be opened should not be in a "xdCanOpenInReadOnlyMode". The Code that I have know is the following: function CTRL242_6::OnClick(eventObj) //button-onclick-event { function openFormB() //your MY_CODE_THAT_OPENS_FORM_B()-function { var sSharePointTemplate = "http://sharepoint.company.com/name/Forms/template.xsn"; var oXDoc = Application.XDocuments.NewFromSolutionWithData(XDocument.DOM.documentElement, sSharePointTemplate, 1); thisApplication.XDocuments.Open(sForm, (int)XdDocumentVersionMode.xdCanOpenInReadOnlyMode); } var xdFormB = openFormB(); // Set namespaces here. XDocument.DOM.setProperty("SelectionNamespaces", '... xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-02-14T14:04:34" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"'); var sFormAFieldValue = XDocument.DOM.selectSingleNode("/my:meineFelder/my:id_form").text; xdFormB.DOM.selectSingleNode("/my:meineFelder/my:id_form).text = sFormAFieldValue; } Sorry, about the german words (like meineFelder), but I use the german IP-version. I cannot test the code at the moment, since I do not point, like I can/should open form B. I hope you can help me to finish this. For now thanks a lot for your time, that you spend at my problem. Greetings Matthias 03-08-2007 09:22 AM In reply to Greg Collins Joined on 08-07-2006 Posts 2,126 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact Hi. Hopefully we're coming to a final solution for you... First thing is you cannot place a function (openFormB) inside another function (CTRL242_6::OnClick)... that will have to be moved outside the other function... Also, I'm not sure that in your case you need to use NewFromSolution**WITHDATA***... you probably only need NewFromSolution(). Please refer to the InfoPath internal help or the MSDN web site for help with these functions. Please note that I haven't tested any of the changes I'm making to the code you provided above... I'm just making changes here inline... function CTRL242_6::OnClick(eventObj) //button-onclick-event { var xdFormB = openFormB(); // Set namespaces here. xdFormB.DOM.setProperty("SelectionNamespaces", '... xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-02-14T14:04:34" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"'); var sFormAFieldValue = XDocument.DOM.selectSingleNode("/my:meineFelder/my:id_form").text; xdFormB.DOM.selectSingleNode("/my:meineFelder/my:id_form).text = sFormAFieldValue; } function openFormB() //your MY_CODE_THAT_OPENS_FORM_B()-function { var sSharePointTemplate = "http://sharepoint.company.com/name/Forms/template.xsn"; var oXDoc = Application.XDocuments.NewFromSolution(sSharePointTemplate); return oXDoc; } Maybe this will help. Please Visit:BraintroveGreg's Paintings 03-09-2007 01:32 AM In reply to Smeets Joined on 02-21-2007 Posts 24 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact Thanks. Opening Fomrular B works perfectly. However the onclick event not as planned. The form leaves itself to open, but as soon as I merge the following two lines, in the preview I get the error: "the selected form cannot be opened by InfoPath" var sFormAFieldValue = XDocument.DOM.selectSingleNode("/my:meineFelder/my:id_form").text; xdFormB.DOM.selectSingleNode("/my:meineFelder/my:id_form).text = sFormAFieldValue; I think because of the XDocument. First I have the namespace xdFormB.DOM.setProperty("...") integratet, how you had meant it. Then I have additionally still inserted the namespace XDocument.DOM.setProperty("..."), but the error emerged again. What could it still be that it does not recognize these two code lines, and how I know to take the value (in the meantime no more bezeichnungderveranstaltung) from the text field id_form from form A and insert it into the text field id_form (no more schulung) in form B? I think we stand briefly before the solution of the problem. I find it also great that you support me so intensively. 03-09-2007 09:50 AM In reply to Greg Collins Joined on 08-07-2006 Posts 2,126 Re: Delivery of value between form A to form B Mark as Not AnswerMark as Answer... Reply Contact You will not need to set XDocument.DOM.setProperty("...") because this is done at the top of the script file. It only needs to be done one time. I have created a simple 2 Form sample that you can download here. It has Form A and Form B. Form A has a text box and a button. Type anything into the text box and click the button to open Form B and populate the text box in Form B with the value you typed into the text box in Form A. When you get the .zip file, extract both .xsn files to C:\ because this is where they are expected to be. Let me know if this helps. Please Visit:BraintroveGreg's Paintings Page 2 of 3 (35 items) < Previous 1 2 3 Next > Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.