How do I capture the form fillers name in Infopath? RRS feed

  • Question

  • I can't use created by since it is not there until the form is submitted. I need to be able to capture the name of the person filling out the form in a field without programming.
    Wednesday, December 21, 2011 3:46 PM


All replies

  • =username()
    Wednesday, December 21, 2011 4:05 PM
  • Use GetUserprofile service to get fullname. Inbuilt username() function will give accountid.


    Hope this helps.


    Dare to promise
    Thursday, December 22, 2011 3:50 PM
  • Hi peter,

    To get the Form filler User name. Please follow the below steps.

    • Go to tools --> Data connection --> click on the Add
    • select an option "Receive Data"
    • Select a Web Service Option
    • place a web service url like http://<servername>/_vti_bin/UserProfileService.asmx
    • select GetUserProfileByName option
    • click next, next, next
    • select checkbox "Automatically retrieve data when form is opened"
    • click on finish.

    Drag and drop text box to your form.

    1. Double click on the textbox --> click on fx button --> click on insert field or group button
    2. From data source dropdown select GetUserProfileByName connection. Expand data fields folder until Values folder
    3. Under Values folder --> Value data then -->select value
    4. Click on Filter button --> click on Add button
    5. from first dropdown, select a field or group option
    6. then form data source dropdown select GetUserProfileByName connection. Expand data fields folder until Property data folder
    7. Under Property data --> select Name
    8. From Second dropdown select Equal To
    9. In Third Dropdown select type text and type "PreferredName" and click all Oks

    it will be Value[Name = "PreferredName"]

    hope this will work....

    Wednesday, December 28, 2011 12:07 PM
  • Thanks but when I create the data connection I can no longer open forms created with the template. I get an error telling me the form template is not valid and on opening details I see:

    Server was unable to process request. ---> Attempted to perform an unauthorized operation.

    So I guess I'm not allowed to use the service.

    Thursday, December 29, 2011 5:23 PM
  • Hi Peter,

    You need to adjust the security settings of your form:

    Form Options > Security & Trust > Try "Domain" level

    *Domain does not mean what you think it means - it doesn't mean the entire domain.  It means the same server.  But you should be connecting to your userprofileservice on the same server as the SharePoint site so that should do the trick.


    Thursday, December 29, 2011 6:26 PM
  • I doesn't work for me at any security level.


    I'm guessing it has to do with userprofileservice not being configured properly. If I cut and paste  http://<servername>/_vti_bin/UserProfileService.asmx replacing servername with the URL for the server it takes me to the correct page but when I drill down on GetUserProfileByName all I see is sample 1.1 and 1.2 SOAP code.

    Does that mean this was never set up?

    Thursday, December 29, 2011 6:48 PM
  • Nope, that's all I see too on my working GetUserProfileByName.  What account are you using to test this (your not using an account used as an SP service account, are you?).

    Do you get the error during preview mode, or only when you try to open the form from the SharePoint library?

    Thursday, December 29, 2011 7:09 PM
  • Both.

    Is it likely that we are not given access to this? I'm the site owner for my customers site but they are a very small piece of a large SP farm. We don't have any control over server level access. 

    Oh, to answer your other question I'm using my user account. No service accounts involved.
    Thursday, December 29, 2011 7:18 PM
  • Hmm,

    Try using the url of the customer site instead; i.e.:


    Also, when you go to preview the form - before you get the error do you get a security warning box asking if you want to allow the data connection? Something similar to this:  http://www.k2underground.com/cfs-file.ashx/__key/CommunityServer.Components.PostAttachments/

    Thursday, December 29, 2011 7:27 PM
  • Hmm, we could be making progress here. Error message gone. When I use <customersite> plus the path to userprofileservice in a browser it takes me directly to a page of code.

    It works. Thanks Melissa and Mohammed for your able assistance. :)

    Thursday, December 29, 2011 8:52 PM