Infopath form loading very slowly and asking like-A script in this page causing IE to run slowly - InfoPath Dev
in

InfoPath Dev

Infopath form loading very slowly and asking like-A script in this page causing IE to run slowly

Last post 05-31-2010 06:33 AM by Qazi Anis. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 05-26-2010 11:21 PM

    Infopath form loading very slowly and asking like-A script in this page causing IE to run slowly

    Hi i have a sharepoint list with columns as ID and NAME. The list contains around 1lakh items and they may grow in future too..

    when i am opening the form it loads very slowly and fires an alert box saying -- A script in this page causing IE to run slowly. Do you want to abort script?

    when i tried to fetch the NAME from the list by entering ID,then also it is fires the alert message.

    How to overcome this...pls reply as early as possible

     

     

  • 05-27-2010 08:41 AM In reply to

    Re: Infopath form loading very slowly and asking like-A script in this page causing IE to run slowly

    Hi,

    It sounds like the size of the SharePoint list could be causing the issue.  This is a known issue with InfoPath and SharePoint - InfoPath is actually unable to do any server side filtering of the SharePoint list which means that InfoPath will return the entire list from SharePoint as a secondary data source and then any filtering etc you need to do will be done in the form itself.  SharePoint 2010 made some imrovements to this but we also have a product called "Web Services Solution Pack" (WSSP) that allows you to query SharePoint and or SQL DB's much more efficiently than out of the box InfoPath/SharePoint

    http://www.qdabra.com/en/products/WSSP.aspx

    We do offer a free trial version

    Ted

  • 05-28-2010 01:14 AM In reply to

    Re: Infopath form loading very slowly and asking like-A script in this page causing IE to run slowly

    Hi,

    I got it..BUT...

    Below is my code:

    using Microsoft.Office.InfoPath;

    using System;

    using System.Xml;

    using System.Xml.XPath;

    namespace Template1

    {

    public partial class FormCode

    {

    // Member variables are not supported in browser-enabled forms.

    // Instead, write and read these values from the FormState

    // dictionary using code such as the following:

    //

    // private object _memberVariable

    // {

    // get

    // {

    // return FormState["_memberVariable"];

    // }

    // set

    // {

    // FormState["_memberVariable"] = value;

    // }

    // }

    // NOTE: The following procedure is required by Microsoft Office InfoPath.

    // It can be modified using Microsoft Office InfoPath.

    public void InternalStartup()

    {

    EventManager.XmlEvents[
    "/my:myFields/my:group1/my:group2/my:field1"].Changed += new XmlChangedEventHandler(field1_Changed);

    }

    public void field1_Changed(object sender, XmlEventArgs e)

    {

    // Retrieve the value of the itemID field

    XPathNavigator root = MainDataSource.CreateNavigator();

    string itemid = root.SelectSingleNode("//my:field1", NamespaceManager).Value;

    // Retrieve a reference to the SharePoint list

    XPathNavigator secDS = DataSources["RMSDATA"].CreateNavigator();

    // Search for the item ID in the SharePoint list

    XPathNavigator itemname = secDS.SelectSingleNode("/dfs:myFields/dfs:dataFields/dfs:RMSDATA[@RMSID = '" + itemid + "']",

    NamespaceManager);

    // Check whether the search returned a result and

    // if it did, retrieve the name of the item

    string rmsname = string.Empty;if (itemname != null)

    {

    rmsname = itemname.SelectSingleNode(
    "@RMSNAME", NamespaceManager).Value.ToString();

    }

    // Select the contact in the textbox

    root.SelectSingleNode("//my:field2", NamespaceManager).SetValue(rmsname);

     

    }

    }

    }

     But it fetching the items in the firstview only..that is if the item id is in first 100 then only it loads the item name.

    Totally i have seventy thousand items....any idea????

     

  • 05-28-2010 03:17 AM In reply to

    Re: Infopath form loading very slowly and asking like-A script in this page causing IE to run slowly

     hi,

    i would suggest since you have over 70k data items, dont use secondary data connection, just use share point object model to fetch data from a list on the change event and fetch only the item whose ID is given.

    that would give a huge performance boost to your form, and  you form will load much faster.

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 05-28-2010 11:47 PM In reply to

    Re: Infopath form loading very slowly and asking like-A script in this page causing IE to run slowly

    Hi anis.

    I have tried like below......

    but it throws an error..

    can u pls check once..

    public void field1_Changed(object sender, XmlEventArgs e)

    {

    try

    {

    XPathNavigator root = MainDataSource.CreateNavigator();string itemid = root.SelectSingleNode("//my:field1", NamespaceManager).Value;

     

    //SPSite RmsSite = SPContext.Current.Site;

    SPSite MySite = null;

    SPWeb MyWeb = null;

    SPSecurity.RunWithElevatedPrivileges(delegate()

    {

    SPSite RmsSite = new SPSite("sitename"); //sitename

    SPWeb RmsWeb = RmsSite.OpenWeb();

    SPList RmsList = RmsWeb.Lists["RMSDATA"];

     

    SPQuery query = new SPQuery();

    StringBuilder sb = new StringBuilder();

    sb.Append("<Where>");

    sb.Append("<Eq><FieldRef Name='RMSID' /><Value Type='Value'>" + itemid + "</Value></Eq>");

    sb.Append("</Where>");

    query.Query = sb.ToString();

    SPListItemCollection RmsCollection = RmsList.GetItems(query);

    string rmsname = string.Empty;

    foreach (SPListItem item in RmsCollection)

    {

    if (item["RMSID"].ToString() == itemid)

    {

    rmsname = root.SelectSingleNode(
    "@RMSNAME", NamespaceManager).Value.ToString();

    }

    root.SelectSingleNode(
    "//my:field2", NamespaceManager).SetValue(rmsname);

    }

    });

     

     

    }

    catch (Exception ex)

    {

    string Err = ex.Message;

    }

     

    }

    }

    }

  • 05-28-2010 11:49 PM In reply to

    Re: Infopath form loading very slowly and asking like-A script in this page causing IE to run slowly

    sorry i forgot to say abt the error.it is "object reference not set to an instance of object" at Runwith elivated privileges delegate.

    Thanks.

  • 05-29-2010 05:13 AM In reply to

    Hi i have implimented using Object model..but getting errors like...

    Hi Anis,

    I am new to programming...so please help me..i am struggling with this from the last two days..

    I have made some changes in my code..But the problem is i can't debug my code to check whether it is right or not??

    I am getting Null Reference Exception:Object is not referenced to an instance of object like that.

    So pls pls check my code...give me u r suggestionss..

    public void InternalStartup()

    {

    EventManager.XmlEvents[
    "/my:myFields/my:group1/my:group2/my:field1"].Changed += new XmlChangedEventHandler(field1_Changed);

    }

    public void field1_Changed(object sender, XmlEventArgs e)

    {

    XPathNavigator root = MainDataSource.CreateNavigator();string itemid = root.SelectSingleNode("//my:field1", NamespaceManager).Value;

     

    try

    {

    SPSecurity.RunWithElevatedPrivileges(delegate()

    {

    SPSite RmsSite = new SPSite("http://abc:333");

    SPWeb RmsWeb = RmsSite.OpenWeb();

    RmsWeb.AllowUnsafeUpdates = true;

    SPList RmsList = RmsWeb.Lists["RMSDATA"];

    SPQuery query = new SPQuery();

    StringBuilder sb = new StringBuilder();

    sb.Append("<Where>");

    sb.Append("<Eq><FieldRef Name='Title' /><Value Type='Value'>" + itemid + "</Value></Eq>");

    sb.Append("</Where>");

    query.Query = sb.ToString();

    SPListItemCollection RmsCollection = RmsList.GetItems(query);

    string rmsname = string.Empty;

    foreach (SPListItem item in RmsCollection)

    {

    for (int i = 0; i < RmsCollection.Count; i++)

    {

    rmsname = item[
    "RMSNAME"].ToString();

    }

    }

    root.SelectSingleNode(
    "//my:field2", NamespaceManager).SetValue(rmsname);

     

     

    });

    }

     

    catch (Exception ex)

    {

    string Err = ex.Message;

    }

    }

     

    Regards,

    Bala

  • 05-30-2010 10:31 PM In reply to

    Re: Hi i have implimented using Object model..but getting errors like...

     hi Bala,

    why dont you just debug your code, i know you told you cant debug your code.. but i think you should be able to. 

    to debug your code, just put debug points in your code and press F5. 

    Also to create the scenario's easily you can specify preview form. to specify that go to file -> preview -> preview settings and specify the xml file to be used to open by default.

    do tell me if you are not able to do so. 

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 05-30-2010 10:56 PM In reply to

    Re: Hi i have implimented using Object model..but getting errors like...

    Hi Anis,

    in the priview settings i have mentioned the domain name ..but in sample data..i have done like below..

    To specify a sample data file to use while debugging or previewing in VSTA

    1. To view template.xml, open the form template in InfoPath design mode.

    2. On the File menu, click Save As Source Files, save the form template files to a folder, and then open the template.xml file in a text editor.

    3. Create and save a file with the same structure as template.xml with the sample data you want to use.

    4. On the File menu, click Preview, and then click Preview Settings.

    5. Under Sample Data, specify your sample data file   

    6. In the sample data i took as..<my:group1>
        <my:group2>
         <my:field1>XY123458</my:field1>
         <my:field2>Bala</my:field2>
        </my:group2>
       </my:group1>

    7. When i tried to debug --these two fields automatically populating in the texboxes and not hitting the breakpoints.

  • 05-30-2010 11:13 PM In reply to

    Re: Hi i have implimented using Object model..but getting errors like...

    Hi Anis,

    i can debug now..

    and when at opening the site like spsite mysite=spcontext.current.site. getting following xception.

    A first chance exception of type 'System.NullReferenceException' occurred in secondrms.DLL

     

     

  • 05-31-2010 06:33 AM In reply to

    Re: Hi i have implimented using Object model..but getting errors like...

     you need to execute this code from a machine having moss/sharepoint installed. you cant debug this code from your local machine

    Qazi Anis
    Technical Architect
    Bitwise Inc
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.