locked
Use SharePoint users info in InfoPath and workflow RRS feed

  • Question

  • I'm working on a custom trouble ticket form that will save to a form library and then kick off an approval workflow. I have the list of valid approvers in a "Person or Group" column in a separate Approvers list in SP, and the approvers are successfully loading into a dropdown box (datatype text/string) in the InfoPath form.

    My question is: how do I get the workflow to use the selected Approver from the InfoPath form? When I publish the form and demote the Approver name, a text column is created in the form library. Then in the workflow step to assign a Task to the Approver, the task is created when the form is saved to the library, but the approver in the task is blank. I think it's because the Approver column is not a "Person or Group" column.

    I'm comfortable with SharePoint, but new to InfoPath and workflows (using SP Designer), so maybe this isn't the right approach?

    thanks
    Tuesday, April 29, 2008 1:03 PM

Answers

  • I ended up finding a different solution within InfoPath. To restate the problem I was having, I had a list of users stored in a list in SharePoint, specifically in a "Person or Group" column. The InfoPath form would read that list into a drop-down box and a user could be selected. When the form was saved to a SharePoint form library, the demoted field would be stored in the form library as a text field, which I could not get workflow to use as a task owner (since it was just the user's full name, not the domain account).

    The suggestion above was to do a lookup inside the workflow to get the domain account from the full name, but for some reason I wasn't able to get the user list to show up in SP Designer. But, I was able to get to the "User Information List" to show up in InfoPath. That allowed me to do a lookup using the full name and get the domain account, which I then stored as a hidden field on the form. It still was demoted as a text field, but because it was in the right format, workflow was able to use it to assign tasks and send emails.

    To use the User Information List in InfoPath, first link to the list using the data connection wizard:
    • Tools->Data Connections
    • Add
    • Create a new connection to: Receive data
    • Select "Sharepoint library or list" as the source of your data
    • Enter the root level of your SharePoint site
    • Select the User Information List
    • Check the fields that you'll need. For me, I needed the Name and Account fields
    • Don't store a copy of the data in the form
    • Give the data connection a name (default is "User Information List", and check the "Automatically retrieve data when form is opened" box
    Then to do the lookup, follow these steps:
    • Add a text box control to your form and double-click to get to its properties
    • On the Data tab, click the fx button in the Default Value section
    • Click the "Insert Field or Group..." button
    • Change your data source to "User Information List"
    • Expand the folders until you can see the fields in the list
    • Select :Account (but don't click ok yet)
    • Click the "Filter Data..." button
    • Add a filter
    • In the filter conditions, choose "Name" in the first box
    • Leave "is equal to" in the second box
    • In the 3rd box, choose "Select a field or group..."
    • Change the Data source to "Main"
    • Click the field on the form that holds the name the user selected, in my case that's the Approver field.
    • Click Ok until you're back to the form
    Now when you select your Approver, the text box just created uses the full name that was selected, finds that name in the User Account List, and retrieves the domain account info. I was able to use that domain account info in workflows.
    Monday, May 12, 2008 6:05 PM

All replies

  • You're correct that it doesn't work because the Approver column is not a "Person or Group" datatype.

     

    The first thing to try would be to store the domain account name of the user rather than the person's name. You might have better luck.

     

    Assuming you're using SharePoint Designer to create the workflow, you may need to do a lookup against the User Information List to get the ID of the item where the name matches the value promoted in the Approver column. You can then set a Person or Group field using this ID value.

     

    Here's how you can get this value without creating a custom workflow activity:

    - In SPD, open the Properties window for the "\_catalogs\users" list and uncheck the "Hide from browsers" option on the Settings tab.

    - In the Workflow designer, add a variable named "Approver ID" with a type of "List Item ID".

    - Add an action to "Set Workflow Variable" and select "Approver ID" as the workflow variable.

    - Click the f(x) button to show the Define Workflow Lookup dialog box.

    - Choose "User Information List" from the Source dropdown, then select "ID" from the Field dropdown in the Lookup Details section.

    - Under the Find the List Item section, choose "User Information List:Name" or "User Information List:Account" for the Field, depending on whether your Approver field contains the person's name or the person's login ID.

    - Click the f(x) button for the Value, leave the Source set to Current Item, and choose the Approver field from the Field dropdown.

     

    At this point, you now have a variable containing the ID of the person. If you add another column to your list with a "Person or Group" type, you can set the column value using this variable.

    Wednesday, April 30, 2008 2:50 AM
  • Thanks for the reply. That's making sense to me, however I don't have a users list under _catalogs, just "fpdatasources" and "masterpage (Master Page Gallery)"

    Is that a permissions issue?
    Wednesday, April 30, 2008 5:43 PM
  • A related problem I'm having is that I can't get the approver's Domain account ID to show up in the form. I've got the Approvers drop-down in the form that's successfully loading the Approvers preferred name from my Approvers list in SharePoint (approver is stored in a "Person or Group" column).

    I would like to have the domain\accountname be pulled into my form instead of the preferred name, but I haven't found any options for specifying the type of data to get from the SP list.
    Thursday, May 1, 2008 5:06 PM
  • The users list only exists in the top-level site for the site collection.

     

    Friday, May 2, 2008 12:00 PM
  •  

    Thank you so much for creating this post.  This was driving me mad. 

     

    I needed to set a new ListItem's "Created By" field using workflow.  This was working fine for AD-based users, but when i need to set this field to a Forms-based user (SQL/ASPNET Membership provider) the workflow kept failing with "Error updating a list item".

     

    This is now working thanks to your post, and google for indexing it!

     

     

    Ian Cooper

    Friday, May 2, 2008 12:52 PM
  • Ok, slowly making progress but not there yet. We were able to make _catalogs\users visible, and uncheck the "Hide from browsers" option. However, I'm not getting "User Information List" as an option in the workflow lookup.

    Is there anything specific I can look for as to why that's not showing up?
    Monday, May 5, 2008 4:02 PM
  • I ended up finding a different solution within InfoPath. To restate the problem I was having, I had a list of users stored in a list in SharePoint, specifically in a "Person or Group" column. The InfoPath form would read that list into a drop-down box and a user could be selected. When the form was saved to a SharePoint form library, the demoted field would be stored in the form library as a text field, which I could not get workflow to use as a task owner (since it was just the user's full name, not the domain account).

    The suggestion above was to do a lookup inside the workflow to get the domain account from the full name, but for some reason I wasn't able to get the user list to show up in SP Designer. But, I was able to get to the "User Information List" to show up in InfoPath. That allowed me to do a lookup using the full name and get the domain account, which I then stored as a hidden field on the form. It still was demoted as a text field, but because it was in the right format, workflow was able to use it to assign tasks and send emails.

    To use the User Information List in InfoPath, first link to the list using the data connection wizard:
    • Tools->Data Connections
    • Add
    • Create a new connection to: Receive data
    • Select "Sharepoint library or list" as the source of your data
    • Enter the root level of your SharePoint site
    • Select the User Information List
    • Check the fields that you'll need. For me, I needed the Name and Account fields
    • Don't store a copy of the data in the form
    • Give the data connection a name (default is "User Information List", and check the "Automatically retrieve data when form is opened" box
    Then to do the lookup, follow these steps:
    • Add a text box control to your form and double-click to get to its properties
    • On the Data tab, click the fx button in the Default Value section
    • Click the "Insert Field or Group..." button
    • Change your data source to "User Information List"
    • Expand the folders until you can see the fields in the list
    • Select :Account (but don't click ok yet)
    • Click the "Filter Data..." button
    • Add a filter
    • In the filter conditions, choose "Name" in the first box
    • Leave "is equal to" in the second box
    • In the 3rd box, choose "Select a field or group..."
    • Change the Data source to "Main"
    • Click the field on the form that holds the name the user selected, in my case that's the Approver field.
    • Click Ok until you're back to the form
    Now when you select your Approver, the text box just created uses the full name that was selected, finds that name in the User Account List, and retrieves the domain account info. I was able to use that domain account info in workflows.
    Monday, May 12, 2008 6:05 PM
  • Actually, there might even be an easier way.This is an old post from Scott Heim's blog, but the gem is in the comments below regarding resolution of the name.

     

    This is the blog entry:

    http://blogs.msdn.com/infopath/archive/2007/02/28/using-the-contact-selector-control.aspx


    This is the comment:

    http://blogs.msdn.com/infopath/archive/2007/02/28/using-the-contact-selector-control.aspx#5392227

     

    The web service that the contact picker control uses to resolve names within infopath forms and aspx forms is

     

    http://server/_vti_bin/people.asmx

     

    In your case you would provide the query string the name from your drop down, then query the web service to return whatever data you wanted of that user.

    Thursday, June 5, 2008 3:04 PM