SharePoint List Infoapth Form:pre populate from query string



  • Hi,


    To create a new editform.aspx or dispform.aspx, you can easily do it through SharePoint designer 2010 >  lists ad libraries > click your library > forms section > click new button in this setion.

    Or you can also create a new page in visual studio 2010 and add code into the code-behind to populate the data you want based on the parameter in the URl in this form.




    • ทำเครื่องหมายเป็นคำตอบโดย Seven M 3 มีนาคม 2554 0:59
    1 มีนาคม 2554 7:25
  • Thanks for the idea Seven. But I already came up with a solution of using Query string Url filter web part to pass parameter to the infopath web part.
    • ทำเครื่องหมายเป็นคำตอบโดย Seven M 3 มีนาคม 2554 0:59
    2 มีนาคม 2554 14:46
  • Hi Aparna,

    Can you explain me the process of how you passed the query string.



    17 พฤษภาคม 2554 20:30
  • These are the steps involved :

    1. Create a page InfoForm.aspx with the following web parts:

        a. InfoPath form web part: Add your form which contains a text field-f1 to populate the data from other page passed     through  Query string URL parameter.

       b. Query String URL web part: Give the query string parameter name as "dataPassed" and in the Advanced Filter Options select the third option: combine them into a single value and delimit with ';' if you are passing multiple values with dataPassed parameter. And connect this filter with the infopath web part passing this parameter value to field-f1.

    2. Now we need to make sure that we pass the Query string in the URL when we call that page like this: http://servername/Pages/InfoForm.aspx?dataPassed=V1&dataPassed=V2&dataPassed=0

    For this I created an option in the Doc lib item's context menu called "Create InfoPath Form" and added javascript using Content Editor Web part to raise an event to redirect to the URL in the above format.

     <script language="javascript">

    function Custom_AddDocLibMenuItems (m.ctx)


      var strDisplayText = "Create infopath form";

    var strAction;
    var strImagePath = "";
    // parse the URL out of the itemTable
    var URL = "";
    var source = "";
    var index = itemTable.innerHTML.indexOf("href=");
    if (index > 0)
      var str = itemTable.innerHTML.substr(index + 6);
      index = str.indexOf('"');
      if (index > 0)
        URL = str.substr(0, index);
        URL = URL.replace(/%20/g,"%2520");

    if (URL != "")

    //Here I am passing the Item URL, ID and some value 0..
    strAction = '"http://servername/Pages/InfoForm.aspx?dataPassed= '+ URL +'&dataPassed='+ currentItemID +'&dataPassed='+0+'","mywin","width=400,height=200,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes")'

    // Add menu item
      CAMOpt(m, strDisplayText, strAction, strImagePath);

       // add a separator to the menu
    return false;

    Thats it, when we click on the context menu option it will redirect to the InfoForm.aspx page and query string web part helps in passing the dataPassed values delimited with semi colon to the form. And we can use substring() in infopath to seperate the data and use it wherever required.

    Let me know if you have any more questions.

    Thank you.

    18 พฤษภาคม 2554 15:17
  • Thanks for the idea Seven. But I already came up with a solution of using Query string Url filter web part to pass parameter to the infopath web part.
    I am doing the exact same thing, but I can't pass in the ID value. For example, I can pass ?ID=1 to the editfs.aspx page and get the edit value for ID 1. I do this same exact thing using the InfoPath Form Webpart and it does not work. I used the URL Filter Web Part and it does nothing for at least the ID value isn't working.
    22 มิถุนายน 2555 16:13