locked
Passing parameters to Infopath web part to load data RRS feed

  • Question

  • I have a site page with an Infopath form web part from an External List. When page loads I need to fulfill two conditions:

    • If there is none list item found (based on parameters), then form inserts a new item list on submit
    • Else (if there is a list item found) form loads this item data and allows user to edit it

    Parameters should be login name and today date. I guess I can achieve this information from Filters Web Parts, but I don't know how to pass this parameters so the form loads data properly.

    Thanks for any help


    SQL Server 2008 MCITP Database Administrator SQL Server 2008 MCTS Database Developer Oracle 10g OCA

    Friday, September 14, 2012 4:49 PM

Answers

  • I found I can't connect a Infopath Form Web Part with my External List Web Part. The option to "Get Form From" isn't enabled when dealing with External Lists. Had to use a Standard List.

    So I gonna have to develop some solution to export from the list to my database, but I can live with that. I just don't get why isn't this explicit in any documentation I've read. There's a lack of information when handling stuff with BCS.

    Thanks for your help, Emir.


    SQL Server 2008 MCITP Database Administrator SQL Server 2008 MCTS Database Developer Oracle 10g OCA

    • Marked as answer by lero.dba Friday, September 21, 2012 2:17 PM
    Friday, September 21, 2012 2:17 PM

All replies

  • Hi lero,

    According to your requirement, you want to pass current user and current date to the field in a form displayed in InfoPath Form Web Part. But, maximum number of connection allowed for InfoPath Form Web Part is 1. So we can only pass one of the filters from current user and date filter web part. Similar like step in this blog to pass parameter from a query string filter web part. But this solution is not work for your requirement.
    http://blogs.msdn.com/b/infopath/archive/2010/06/03/how-to-pass-querystring-data-into-an-infopath-form.aspx

    Instead of use filter web part, we can directly give a default value to the form field. We can use username() function in InfoPath form to get current login user, and today() function to get current date.

    External list is not supported to custom list form in InfoPath. Do you create such form yourself (with code behind)? I’m littler confused and need to be declare, by default, a custom list form created from a custom list displays in a InfoPath Form Web Part can only use to create new list item but not possible to update list item.

    Thanks & Regards,
    Emir


    Emir Liu

    TechNet Community Support

    Monday, September 17, 2012 8:25 AM
  • Hello Emir.

    Thank you for your response. In fact my description is very poor mainly because I don't know a bit about Infopath. I took some shots to try a better explanation.

    I've the following Infopath form:

    This form is a kind of "punch card". Every time an user enters the page (not the list itself) the form loads and he can submit it successfully writing in my external list.

    Next time my user returns the page, he should see the loaded with previous information. Example:

    Each button does a "punch". The rules applied are: set corresponding field value then submit the form.

    When I edit the form trough the list I achieve this out-of-the-box from Sharepoint. But when I insert the form inside a page I don't know how to tell it to load the corresponding item in my list. All I can do is open a new form which inserts a new item on submit.

    I found I can set form parameters public. I've already set this in the field ID_Ponto (my table primary key). What I don't know is how I can retrieve this field value and pass to my form.


    SQL Server 2008 MCITP Database Administrator SQL Server 2008 MCTS Database Developer Oracle 10g OCA

    Monday, September 17, 2012 2:53 PM
  • Hi lero,

    Instead of display the form in InfoPath form web part, you can directly open the saved form itself in browser.

    If you still want to display the form in InfoPath form web part, you can pass the field ID_Ponto in query string and pass it to a form field using query string filter web part. (You can follow the blog in my first post).

    Then custom the InfoPath form in InfoPath Designer, create a data connection to receive data from your list. Then we can get all items in that list.
    http://office.microsoft.com/en-us/infopath-help/add-a-data-connection-to-a-sharepoint-document-library-or-list-HP010093160.aspx#BM3

    Use filter to get the one item you need. For example, we need to find the Entrada 4, then we can add a default value or use action rule to set a field to it: Set value = second data source you created in above step, select Entrada 4 field > Click Filter button > Select ID_Ponto = ID_Ponto field in Main data source. (You can find some demos to filter data source in InfoPath).

    Thanks & Regards,
    Emir


    Emir Liu

    TechNet Community Support

    Tuesday, September 18, 2012 10:22 AM
  • Emir,

    I appreciate your help. I think I'm closer to what I want now.

    As my form is from an External Content Type I can't add extra data connections. I know I can build a totally custom Infopath form to do this, but I prefer to keep things simple using the same form from my External List.

    What I did until now:

    • Reformulate my External Content Types filters to a single filter (filtering username)
    • Create a list view passing username in Finder and filtering an sorting Entrada 1 for Descending
    • Connecting list view web part with Infopath form web part

    So now I get the list item I want on page load, but connection with Infopath form isn't working. I select my list item but form doesn't load data. Don't know what's wrong.

    Regards


    SQL Server 2008 MCITP Database Administrator SQL Server 2008 MCTS Database Developer Oracle 10g OCA

    Wednesday, September 19, 2012 6:32 PM
  • I found I can't connect a Infopath Form Web Part with my External List Web Part. The option to "Get Form From" isn't enabled when dealing with External Lists. Had to use a Standard List.

    So I gonna have to develop some solution to export from the list to my database, but I can live with that. I just don't get why isn't this explicit in any documentation I've read. There's a lack of information when handling stuff with BCS.

    Thanks for your help, Emir.


    SQL Server 2008 MCITP Database Administrator SQL Server 2008 MCTS Database Developer Oracle 10g OCA

    • Marked as answer by lero.dba Friday, September 21, 2012 2:17 PM
    Friday, September 21, 2012 2:17 PM