Insert new field and populate automatically - without code? - InfoPath Dev
in

InfoPath Dev

Insert new field and populate automatically - without code?

Last post 08-25-2008 12:28 AM by Shiva. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-11-2008 10:25 AM

    Insert new field and populate automatically - without code?

    Hi,

    I want to keep a history of who has updated my InfoPathForms.  This will be visible to developers in a separate View I have created a Group with repeating field(Updatedby) to store the information.

    When I open the form I can determine who is opening the form.  How do I create a new Updatedby record and populate it with this information - preferably using Rules rather than code.

    Thank you

    Catharine

  • 08-12-2008 08:06 AM In reply to

    Re: Insert new field and populate automatically - without code?

    Hi Catharine,Sorry to say that you can't add the record by using the rules, you can add the "Updatedby" record only by using the code. The steps that you need to follow for writing the code are:1.    Get the username who has opened the form.2.    After getting the user name, get the “Updatedby” record from the “SampleData.xml” and assign the user name to this “Updatedby” record.3.       Add the above “Updatedby” record as child, to the parent node of the “Updatedby” record in “template.xml”. 

    Execute the above steps whenever the user opened the form .By following the above steps you can save history who has updated the InfoPath form.

    Chandrakanth/GGKTech
  • 08-12-2008 08:53 AM In reply to

    Re: Insert new field and populate automatically - without code?

    Thank you for the reply.

    My coding is very limited.  Do you know of any example of the process described that I could use as my starting point ?

    Catharing

  • 08-25-2008 12:28 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Insert new field and populate automatically - without code?

    Hello,

    Here is the code you have to write in your onLaod function,

    IXMLDOMDocument2 sampleDataDom = (IXMLDOMDocument2)thisXDocument.CreateDOM();

    sampleDataDom.async = false;

    sampleDataDom.validateOnParse = false;

    sampleDataDom.setProperty("SelectionNamespaces", "namespace of your form");

    sampleDataDom.load("sampledata.xml");

    IXMLDOMNode nodeFromSampledata = sampleDataDom.selectSingleNode("XPath of repeating field node").cloneNode(true);

    //Setting the update by field value

    nodeFromSampledata.text = "Update by value";

    IXMLDOMNode parentNode = thisXDocument.DOM.selectSingleNode("Parent node path");

    //Inserting the sample node at first position.

    parentNode.parentNode.insertBefore(nodeFromSampledata, parentNode);

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.