Respondida SharePoint List Infoapth Form:pre populate from query string

  • יום רביעי 23 פברואר 2011 16:20
     
     

    Can we populate a field in the editifs.aspx form (created using sharepoint list option in infopath) using Query string?

    I have a document library in which I have an option to create a list form and passing some data of thar particular item in URL. I need to populate that data in the list form.

    Advanced thanks for the reply

כל התגובות

  • יום שלישי 01 מרץ 2011 07:25
     
     תשובה

    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.

     

    Regards,

    Seven

    • סומן כתשובה על-ידי Seven M יום חמישי 03 מרץ 2011 00:59
    •  
  • יום רביעי 02 מרץ 2011 14:46
     
     תשובה
    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 יום חמישי 03 מרץ 2011 00:59
    •  
  • יום שלישי 17 מאי 2011 20:30
     
     

    Hi Aparna,

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

    Thanks,

    VJ


    Sadasivuni
  • יום רביעי 18 מאי 2011 15:17
     
     

    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 = 'window.open("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
      CAMSep(m);
    }
     
    return false;
    }</script>

    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.

  • יום חמישי 08 מרץ 2012 21:38
     
     
    Thank you very much...

    Sadasivuni

  • יום שישי 22 יוני 2012 16:13
     
     
    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.