Setting a field value on a Form to a field on another Form - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Setting a field value on a Form to a field on another Form

Last post 08-31-2007 02:39 AM by B.Shiva Prasad. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 06-19-2007 01:42 PM

    Setting a field value on a Form to a field on another Form

    Hi All,

    Any tips as to how I can set a Field-a value on Form-A to a Field-b on Form-B.

    Eg Scenario - LoginID is Field-a on Form-A

    UserID is Field-b on Form-B

     After logging in when user is shown Form-B, the UserID readonly field should have the LoginID value.

    Thanks,

    Rajeev.

  • 06-19-2007 10:59 PM In reply to

    Re: Setting a field value on a Form to a field on another Form

    hey Rajeev.

    If you are just passing user/login ID it would probably be easier justt to use a Active Directory web service like you can download off the site.  How I have done it in the past is using one form to launch the other form and passing the parameters between the forms.  Other methods would be to put the data into a table or xml file and then pull it for the next form.

    Depends on what exactly you need.

    Here is a sample Java Script that works from the command line or could be called from a form which passes 4 variables.

    //myscript.js

    //parse parameters

    if(WScript.Arguments.count()==4)

    {

    var param1 = WScript.Arguments.Item(0);

    var param2 = WScript.Arguments.Item(1);

    var param3 = WScript.Arguments.Item(2);

    var param4 = WScript.Arguments.Item(3);

     

    }

    //Start the application

    var oApp = new ActiveXObject("InfoPath.Application");

    WScript.Echo("InfoPath Version: " + oApp.Version);

    //Open an InfoPath document from the published template

    var oXDocumentCollection = oApp.XDocuments;

    var oXDocument = oXDocumentCollection.NewFromSolution("http://insideen/sites/HR/HRIS/Shared%20Documents/Test.xsn");

    // Get pointers to the target fields

    var oDpt = oXDocument.DOM.selectSingleNode("//my:Number");

    var oName = oXDocument.DOM.selectSingleNode("//my:Name");

    var oFT = oXDocument.DOM.selectSingleNode("//my:FormType");

    var oTst = oXDocument.DOM.selectSingleNode("//my:Test");

     

    //Update the fields

    oDpt.text = param1;

    oName.text = param2;

    oFT.text = param3;

    oTst.text = param4;

    //Submit the Form

    //oXDocument.Submit();

    //Close up shop

    //oXDocumentCollection = null;

    //oApp.Quit();

    //oApp = null;

  • 08-28-2007 12:19 AM In reply to

    Re: Setting a field value on a Form to a field on another Form

    Hi,

    Sorry, i'm a beginner..where can i put the javascript code if i want to call it from form?

     Thanks.

  • 08-31-2007 02:39 AM In reply to

    Re: Setting a field value on a Form to a field on another Form

    Hi norale,

     To write code on javascript go to Tools --> Programming --> Microsoft script editor  or Alt + Shift + F11. If you want to change the script editor go to Tools --> Form Options --> Advanced tab. In the Advanced tab go to "Programming language" section and select the language from "form code language" drop down.

     

    B.Shiva Prasad
    InfoPath Dev,
    http://www.ggktech.com
    India
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.