Form changes not processed (XmlFormView) - InfoPath Dev
in

InfoPath Dev

Form changes not processed (XmlFormView)

Last post 01-11-2007 12:26 AM by fahlen. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 01-09-2007 08:07 AM

    • fahlen
    • Not Ranked
    • Joined on 12-29-2006
    • Posts 7

    Form changes not processed (XmlFormView)

    Hi,

    I have created an InfoPath form which populates a drop-down list box with data from a web service when the form loads. Then, I've added code that executes on the Changed event for this list box. This code updates the rest of the form, querying a web service (passing the current value of the list box as a parameter).

    This is the code:

    public void pending_Changed(object sender, XmlEventArgs e)
    {
    // Write your code here to change the main data source.

    // Get hold of the datasource for the webservice operation
    DataSource ds = this.DataSources["GetExpense"];

    // Create an XPathNavigator to the node we have to set to query the method
    XPathNavigator guidField = ds.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:GetExpense/tns:guid", this.NamespaceManager);

    // Set the query value to the current Guid
    guidField.SetValue(e.NewValue);

    // Execute the webservice operation
    ds.QueryConnection.Execute();

    // The data will now be in the datasource
    XPathNavigator entryNavigator = this.DataSources["GetExpense"].CreateNavigator();

    // Add the namespaces so we can query the datasource
    XmlNamespaceManager umanager = new XmlNamespaceManager(entryNavigator.NameTable);
    umanager.AddNamespace("dfs", "http://schemas.microsoft.com/office/infopath/2003/dataFormSolution");
    umanager.AddNamespace("tns", "http://tempuri.org/");
    umanager.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-01-02T10:15:45");
    umanager.AddNamespace("xd", "http://schemas.microsoft.com/office/infopath/2003");

    // Get hold of the node we're after
    XPathNavigator formNode = entryNavigator.SelectSingleNode("/dfs:myFields/dfs:dataFields/tns:GetExpenseResponse/my:GetExpenseResult", umanager);

    // Set values of name and date
    this.CreateNavigator().SelectSingleNode("/my:myFields/my:name", this.NamespaceManager).SetValue(
    formNode.SelectSingleNode("//my:name", umanager).ToString());
    this.CreateNavigator().SelectSingleNode("/my:myFields/my:date", this.NamespaceManager).SetValue(
    formNode.SelectSingleNode("//my:date", umanager).ToString().Substring(0, 10));

    this.CreateNavigator().SelectSingleNode("/my:myFields/my:mileageCost", this.NamespaceManager).SetValue(
    formNode.SelectSingleNode("//my:mileageCost", umanager).ToString().Replace('.', ','));

    // Update repeating table with new data
    XPathNavigator ipRepTable = this.CreateNavigator().SelectSingleNode("/my:myFields/my:group1", this.NamespaceManager);
    XPathNavigator wsRepTable = formNode.SelectSingleNode("//my:group1", umanager);
    ipRepTable.ReplaceSelf(wsRepTable);
    }


    This works just fine when the form is executed in InfoPath. However, when I publish the form to Office Forms Server and embed the form in a Web Form using the XmlFormView control, things get more difficult. Well, actually the only problem is that when the selected item in the list box changes, the code for updating the contents of the form is executed, but the form as presented in the browser isn't updated.

    If I click on "Print preview", I get the message:

    "The form contains changes that must be processed before it can be printed. Click OK to update the form, and then try printing again."

    I click OK, and the form is refreshed, showing me the correct data.

    How can I trigger this update/refresh of the XmlFormView control in code? There has to be a way of doing this, I just haven't figured out how yet.

    I hope someone will be able to give me a hint.

    Thanks in advance,
    Markus
  • 01-10-2007 01:25 AM In reply to

    Re: Form changes not processed (XmlFormView)

    Hi Markus,
    You're on the bleeding edge here. I don't know the answer either but I'm guessing that you can add a rule or something in the form that will cause it to be updated. There are a number of things which will refresh the form and there may even be some settings in the browser compat settings tab that help you here - I haven't looked. Let us know what you come up with. This is a good new area.
    Patrick Halstead
    Project Manager at Qdabra
  • 01-11-2007 12:26 AM In reply to

    • fahlen
    • Not Ranked
    • Joined on 12-29-2006
    • Posts 7

    Re: Form changes not processed (XmlFormView)

    Thanks for your reply. I still haven't figured it out, but I'll let everyone know when I do.
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.