InfoPath calling SharePoint Modal Dialog to load xml of another InfoPath Form - InfoPath Dev
in

InfoPath Dev

InfoPath calling SharePoint Modal Dialog to load xml of another InfoPath Form

Last post 10-17-2014 11:43 AM by Douglas. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 10-17-2014 11:43 AM

    InfoPath calling SharePoint Modal Dialog to load xml of another InfoPath Form

     Hi Guys,

     I would like to ask your help to this scenario below (InfoPath and SharePoint 2013):

      - I have a SharePoint Library with (xml) items created by a InfoPath form (to simplify my explanation I will call this form as "A"). In this library there is some fields explicit (I've had to promote some InfoPath fields to SharePoint columns).

     - So, to consult this data, I developed a second  InfoPath form (I will call this form as "B"). In this second form I created a data connection to return all data from the library responsible to storage all xml files created by the form "A".  Into the form "B" I configure the data connection results to been shown as a repeating table.

    - This form "B" is configured to be shown in a custom Web Part that I customized:

    ****************************************************** 

    using Microsoft.Office.InfoPath.Server.Controls;
    using System.Text; 

    // XmlFormView control object to render the browser-enabled InfoPath form.
    private XmlFormView xmlFormView = null;

    // Field to hold the return value from the modal dialog box.
    private TextBox hiddenText = null;
    private string receivedValue = null;

    // Property to store the InfoPath XSN URL.
    [WebBrowsable(true)]
    [WebDisplayName("Form XSN URL")]
    [Description("Relative URL of the InfoPath XSN file.")]
    [Category("Configurations")]
    [Personalizable(PersonalizationScope.Shared)]
    public string FormXSNURL { get; set; }

    protected override void CreateChildControls()
    {
        try
        {
            base.CreateChildControls();

            // Instantiate the XMlFormView object.
            this.xmlFormView = new XmlFormView();

            // Set the editing status to init on initial load.
            this.xmlFormView.EditingStatus = XmlFormView.EditingState.Init;

            // Add to the Web Part controls collection.
            this.Controls.Add(this.xmlFormView);

            this.hiddenText = new TextBox();

            // Hide the text box.
            this.hiddenText.Style.Add("display", "none");
            this.hiddenText.Style.Add("visibility", "hidden");

           // Assign a dummy class to the control so it can be found through jQuery functions.
            this.hiddenText.CssClass = "webparthiddenfield";

            // Add to the Web Part controls collection.
            this.Controls.Add(this.hiddenText);
        }
        catch
        {
            throw;
        }
    }
     

    protected override void OnPreRender(EventArgs e)
    {
        try
        {
            // Determine whether the user has set the FormXSNURL property with InfoPath XSN location.
            if (!string.IsNullOrEmpty(this.FormXSNURL))
            {
                // Configure the XmlFormView control to host the form.
                this.xmlFormView.XsnLocation = this.FormXSNURL;

                // Set the editing status to ensure the control displays the form.
                this.xmlFormView.EditingStatus = XmlFormView.EditingState.Editing;
            }
        }
        catch
        {
            throw;
        }
    }

    ******************************************************

    - I add this web part in a SharePoint Web Part Page, for all users access the consult screen.

    - So, until here, everything works fine. The problem is (my help request):
     
    One of these fields returned by the data connection that I created into the form "B" is the url link responsible to open the form "A" with all xml data loaded. I added a button into the repeating table (I added a column and configured a image button). The objective is use this button to call the Form "A" InfoPath link to be load in a modal dialog (It could be loaded with the SharePoint 2013 native modal). So, I need a code snippet to get the current url of the row and a code snippet to load this url in a modal.

    I am try something like this:

    http://msdn.microsoft.com/en-us/library/office/hh278954(v=office.14).aspx 

    and this code (into the button that I configured into the repeating table):

    ******************* 

     public void CTRL462_5_Clicked(object sender, ClickedEventArgs e)
            {                       
                string XmlLocation = e.Source.SelectSingleNode("/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:XmlLocation", this.NamespaceManager).Value;
                HttpContext.Current.Response.Redirect("http:/mysitecollectionurl/subsite/_layouts/15/FormServer.aspx?XMLLocation=" + XmlLocation + "&ClientInstalled=true&DefaultItemOpen=1&Source=http://mysitecollection/subsite/pagetoconsultitemsofformA.aspx", false);
            }

    ******************** 

    I know that this scenario is specific and is rare to use infopath like a Form consult (generally this is developed in pure .net) but i really need configure this scenĂ¡rio. So i will be really grateful with some help. 

    Could somebody, please, help me with this scenĂ¡rio?

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