Pass Parameter to an unopened form - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Pass Parameter to an unopened form

Last post 03-11-2009 08:00 AM by Svetoslav. 20 replies.
Page 1 of 2 (21 items) 1 2 Next >
Sort Posts: Previous Next
  • 04-11-2007 11:32 AM

    Pass Parameter to an unopened form

    I am trying to pass a parameter from an opened form(service.xsn) to an unopened form (contract_details.xsn).
    During filling out the service form, a user will choose a contract and click on a button to open the contract form and running query to get the deatil of the contract.

    Here is what I have on the modify button in the service form.

    function Modify::OnClick(eventObj)
    {
    var contract;
    XDocument oXdNewForm = thisApplication.XDocuments.NewFromSolution(@"C:\Contract_Details.xsn");
    Contract = oXdNewForm.DOM.selectSingleNode("dfs:dataFields/d:Service/d:Details/@Contract").text;
    oXdNewForm.DOM.selectSingleNode("dfs:queryFields/q:Contracts/@Contract").text = Contract;
    }

    I don't know how to code exactly, so I got this from a previous posting and modified it.

    However, it doesn't work, as I expected. Can someone please help me out.
    All I need is very simple. Get a value from a form and send it to another. Indeed, the form is live, not a saved xml file.
    I know I can do this from a saved xml file, but that doesn't apply to my case.

    Thanks very much.
  • 04-11-2007 12:58 PM In reply to

    Re: Pass Parameter to an unopened form

    Please see my reply to your other post regarding this issue. Also, it would be helpful if you moved this information to that post. If you need fast help coding, we may be able to provide assistance, but we typically don't work for free. The forum is not a place to get free coding, but rather, suggestions and guidance on how to do stuff.
    Patrick Halstead
    Project Manager at Qdabra
  • 04-11-2007 08:15 PM In reply to

    Re: Pass Parameter to an unopened form

    Thanks, Patrick.
    I am not here to asking for coding for me, but for help.
    I thought it will be helpful if I posted some code.

    Sorry about that if I made you feel so.
    I have posted an image regarding my issue on other posting.
    Please advise.
  • 04-11-2007 09:37 PM In reply to

    Re: Pass Parameter to an unopened form

    Hi Troy,
    Sorry - I didn't mean to suggest that you were abusing the forum! You aren't. I just wanted to explain that we're all busy trying to get real work done to and sometimes don't have time to spend an hour on a post. My guess is that it would take some time to understand your problem and figure it out. Anyway, please post as much as you want. I'm just saying that for us to figure out your coding issue is probably going to take more time than we have right now. Sorry for the confusion!
    Patrick Halstead
    Project Manager at Qdabra
  • 04-12-2007 11:12 PM In reply to

    Re: Pass Parameter to an unopened form

    Originally posted by nukkumatti

    HI,

    I guess that is all you need to get an understanding of what to do.


    var secondSolution = Application.XDocuments.NewFromSolution("path where your xsn is stored");
    var customer = secondSolution.DOM.selectSingleNode("my:myFields/my:Main/my:CustomerName");
    //here you can also pass values from your current for (e.g. customer.text = XDocument.DOM.selectSingleNode("my:myField/my:field1");
    customer.text = "Test Customer";


    Hope this helps.

    BTW - Always take care that you don't mix up different programming languages and also make sure that your xPath is correct, sometimes a bit tricky when values coming from secondary datasources.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 04-13-2007 09:09 AM In reply to

    Re: Pass Parameter to an unopened form

    Hi nukkumatti,
    Thanks for your reply.

    This is what I need:


    I have the following(red words) in the Modify button:

    var SalarySolution = Application.XDocuments.NewFromSolution("\C:\\Temp\\Salary.xsn");
    var getid = SalarySolution.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:personal/@id").text;

    (I assume the above line is to get the value of the id field from the current form, is this correct?)
    (However, it generates an error message "Reference to undeclared namespace prefix: 'dfs'")
    (I followhttp://infopathdev.com/howto/tutorials/default.aspx?i=ed2cf0c5895f468995cdd081cf17fead to get some help.)
    (But I don't get anything from the detail.)
    getid.text = "id";
    (Is this the way to send the value to from current form(Personal) to Salary.xsn(Unopened form)?)

    Any advice is appreciate, thanks.
  • 04-16-2007 04:48 AM In reply to

    Re: Pass Parameter to an unopened form

    Hi you are on the right track.

    First thing to try is replace ("\C:\\Temp\\Salary.xsn") with ("C:\\Temp\\Salary.xsn"). I am not sure if your path is incorrect but for me it works without the firs "\".

    var getid = SalarySolution.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:personal/@id").text;

    Yes this line is meant to get the value of the id field but I guess that just the xPath you are using is wrong. A nice way to get the correct xPath is using expression boxes. Drop an exBox to your form and point it to the datasource of your ID drop down list control and then check the "Advanced edit xPath" box to get the correct xPath. This you can then use your selectSingleNode function and i guess everything should work. Also try there to leave the first "/".

     Let me know if it helped.

     

    Listen to Motörhead cos they play Rock'n Roll :)
  • 04-16-2007 08:58 AM In reply to

    Re: Pass Parameter to an unopened form

    Hi nukkumatti,

    This is what I have now:
    1. var SalarySolution = Application.XDocuments.NewFromSolution("C:\\Temp\\Salary.xsn");
    2. var getid = SalarySolution.DOM.selectSingleNode("dfs:dataFields/d:personal/@id").text;
    (However, I still got the error message "Reference to undeclared namespace prefix: 'dfs'")
    3. getid.text = "id";
    (Is this the way to pass the value to the id field on Form2?)

    if we write var getid = xxxxxx.text (line2), then shouldn't we have getid = "id" (line3)?

  • 04-16-2007 11:14 PM In reply to

    Re: Pass Parameter to an unopened form

    I think you mix things up there. 

    Okay again,

    first you have a paramter from your active form which you want to pass to your second solution for example: var parameterTopass = XDocument.DOM.selectSingleNode("my:myFields/my:ID").text; the xPath should point to the drop down list from your picture (on the left side) where the ID is in. If I see this correct this is what you want to pass to the second solution. 

    now you need a reference to your second solution you want to pass your parameter to: var SalarySolution = Application.XDocuments.NewFromSolution("C.\\Temp\\Salary.xsn");

    now pass the paramter of your current solution to your second: SalarySolution.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:personal/@id").text = parameterTopass; and again please verify that your xPath is correct there.

    Listen to Motörhead cos they play Rock'n Roll :)
  • 04-18-2007 07:50 AM In reply to

    Re: Pass Parameter to an unopened form

    Hi nukkumatti,

     Thanks again.

    var Getid = XDocument.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:Name/@id").text;
    var Salary = Application.XDocuments.NewFromSolution("C:\\Temp\\Salary.xsn");
    Salary.DOM.selectSingleNode("dfs:myFields/dfs:queryFields/q:Salary/@id").text = Getid;
                                                  ^^^ <= error message "Reference to undeclared namespace prefix: 'dfs'"

    Namespace defined in the form:
    XDocument.DOM.setProperty("SelectionNamespaces", xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields"
    xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"
    xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');

    I got the xPath from expression box. The first one works, but not the second one.
    Why is that? I don't get it.
    I am almost there. Please help me out.

  • 04-18-2007 09:42 AM In reply to

    Re: Pass Parameter to an unopened form

    Salary is the reference to your second form so you need to specify the xPath of the field of your second form in which you want to write the value of your first form. sorry but i can´t tell you your xPathes, my be it´s just ("my:myFields/my:Id")  ?

     

    Listen to Motörhead cos they play Rock'n Roll :)
  • 04-18-2007 01:10 PM In reply to

    Re: Pass Parameter to an unopened form

    Hi,

    It doesn't work.

    var Topass = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:Name/@id").text;
    var Salary = Application.XDocuments.NewFromSolution("C:\\Temp\\Salary.xsn");
    Salary.DOM.selectSingleNode("/my:myFields/my:id").text = Topass;  <= Still got error message from this line.
    "  Reference to undeclared namespace prefix: 'my'.  "

    The following is my sample database.

    Name

    id

    name

    1

    Jack

    2

    Jason

    3

    John

     

    Salary

    id

    Salary

    1

    $500.00

    2

    $600.00

    3

    $700.00

     

    What should I do? I am gonna go crazy.

  • 04-19-2007 12:47 AM In reply to

    Re: Pass Parameter to an unopened form

    Hey Troy,

     please post the structure for your second forms datasource so that we may find out the xPath together. Sorry that my posts have always a big delay but we are in two completey different time zones.

    Listen to Motörhead cos they play Rock'n Roll :)
  • 04-19-2007 07:50 AM In reply to

    Re: Pass Parameter to an unopened form

    I sent an email to you. I think you probably didn't notice it. If you can give me your email address, I can send you the sample I am working on. I think it's better.

    This is the data structure. It's kind of simple because this is just a sample database.

  • 04-20-2007 12:26 AM In reply to

    Re: Pass Parameter to an unopened form

    Hi Troy,

    I received your eMail. Don't get me wrong now but please stop sending me eMails. I help people in this forum voluntarily and post questions and answers only when I have time for it as I also have a regular job. The mail address is mainly used to get in contact with Patrick or his team. This forum is just great and in my oppinion the best reference you can have regarding some infopath issues, better than any book. You cannot expect that other people do the work for you, usually you had to pay money for that extensive help. There is a bunch of information arround and with a little more investigation you could may be have figured out your problem alone.

    Anyway I had a look on your forms and now it was obvious what was wrong. You need to make your current form aware of the namespace prefixes which are coming form your second form otherwise your active form cannot interpret the ":dfs" for example.

    So here is the code you need:


    var toPass = XDocument.DOM.selectSingleNode("dfs:myFields/dfs:dataFields/d:Name/@id").text; 
    var salary = Application.XDocuments.NewFromSolution("C:\\Temp\\Salary.xsn");                
    salary.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" 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-04-18T13:37:36" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');

    salary.DOM.selectSingleNode("dfs:myFields/dfs:queryFields/q:Salary/@id").text = toPass;

    Listen to Motörhead cos they play Rock'n Roll :)
Page 1 of 2 (21 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.