Retrieve current user name through webservice - InfoPath Dev
in

InfoPath Dev

Retrieve current user name through webservice

Last post 09-12-2012 10:23 PM by Gennady Vanin (Геннадий Ванин, Новосибирск). 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 09-22-2008 07:40 AM

    Retrieve current user name through webservice

    According to several posts the current user name can be retrieved via the UserProfileService.asmx WebService (see http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx). However no matter what user is logged in, I always get back the administrator user (I've found similar posts but no solution). Anybody who knows how this can be solved?

    Thanks,

    DD

  • 09-23-2008 01:11 AM In reply to

    Re: Retrieve current user name through webservice

    Ok, I found a solution for the constant display of the administrator account problem. When a rule is assigned to a textbox, which retrieves the current user via the web service, the rule is executed exactly once (during the creation of the form). So if you create a form as an administrator and open the form as user X afterwards, the form still shows administrator. However when you alter the Tools/Form Options/ Open/Save settings and assign a rule to a textbox during form opening, the rule gets applied each time the form is opened resulting in a display of the "current" user.

  • 09-23-2008 08:24 AM In reply to

    • jrudolph
    • Top 150 Contributor
      Male
    • Joined on 07-02-2008
    • Orlando, FL
    • Posts 67

    Re: Retrieve current user name through webservice

    Just a quick comment.

    If the form is meant to be submitted you will probably want to use a different method, otherwise the submitted form will replace the submitters name with the reviewers name when the form is being reviewed. This is an easy fix depening on what your needs are.

  • 09-24-2008 03:51 AM In reply to

    Re: Retrieve current user name through webservice

    Hello jrudolph,

    Sorry, but I don't understand what you're meaning - why should the submitter change, when the name of the current user is bound to a text box for display?

  • 09-24-2008 05:57 AM In reply to

    • jrudolph
    • Top 150 Contributor
      Male
    • Joined on 07-02-2008
    • Orlando, FL
    • Posts 67

    Re: Retrieve current user name through webservice

    Based on what you have said I would assume that if User 1 fills out the form and submits/saves it, if User 2 opens User 1's form it will trigger your rule again, because unless you have code in the form or a control that you are using to indicate that the form was already created it will be triggered again. Becasue of this User 2's name not User 1's will be displayed.

    Now if there is never an instance where a different user will open User 1's form, ie the form is meant to be filled out and then printed, then obviously this is not an issue. However if this form is meant to be filled out and then submitted to a someone, like a superviosr for approval, then the rule will be triggered and enter the new User's name as the current user. Test this by creating a form and saving it and then having a coworker open it.

    I brought this up because I had the problem of users changing when I first implemented the use of a webservice to pull the current users information, however instead of using a on open rule, I simply set the default value of the text box to the Users Name, using the method that you linked to in your first post, and unchecked the "Update this value..." option, this way the text boxes default value only fired the first time the form was opened.

  • 09-24-2008 06:09 AM In reply to

    Re: Retrieve current user name through webservice

    Got it now - thx :-)

    Doesn't matter in my case, as I just need it for some code behind. Thanks for the clarification.

    DD

  • 07-22-2010 11:05 AM In reply to

    Re: Retrieve current user name through webservice

    Hello!  I am interested in how to fix this method so when I have my form submitted for approval, the name in the Current User Name field remains constant no matter whom the form is sent to. Thanks! 

    William Kreuder
    Horizon Bay Senior Living
    Tampa, Florida
    Email: [email protected]
  • 07-22-2010 02:14 PM In reply to

    Re: Retrieve current user name through webservice

    Add a condition to your OnLoad rule that checks to see if the value is blank before running the query.

    Patrick Halstead
    Project Manager at Qdabra
  • 07-23-2010 05:50 AM In reply to

    Re: Retrieve current user name through webservice

    Do you mean create a rule on the Current User Name field that states:  If Current User Name is = to "blank"?

    If so my question then is what action shoudl be run?  Set a fields value?  Thaks for the help! 

    William Kreuder
    Horizon Bay Senior Living
    Tampa, Florida
    Email: [email protected]
  • 07-23-2010 04:35 PM In reply to

    Re: Retrieve current user name through webservice

    The rule should go in your form's Open rules (under form options for 2003 and 2007, under the Data tab for 2010). The condition for the rule should be "if the field that I'm going to put the user name in is blank" and the rule logic should do whatever needs to be done to get the user name (by IP 2007, we have the userName() function, which takes care of that). So, yes, the action would be to set a field's value (the one you just checked to see if it was blank, and the value would be the userName function.

    Hilary Stoupa

  • 09-12-2012 12:52 PM In reply to

    Re: Retrieve current user name through webservice

    Just a real quick message in response to this (I know this topic is over two years old...) If you have a "filler" enabled form and your users are accessing the form via a different domain (I.E. they are using a home computer to fill out a form on a corporate server) then **take note** that "userName()" will return their *current* username. I.E. Bob, or Dad or Mary. NOT "john.q.public". Best advice is to either

    1.  Web enable the form so that they are filling it out with their domain credentials
    2. Use the "web services" method to return their domain account info - tutorial here
  • 09-12-2012 10:23 PM In reply to

    Shrout1:
    If you have a "filler" enabled form and your users are accessing the form via a different domain (I.E. they are using a home computer to fill out a form on a corporate server) then **take note** that "userName()" will return their *current* username

    More precisely, userName() in Infopath Filler (even opened from sharepoint) returns username with which a user logged-in into its Windows on local/client machine. It can be out of any domain at all. For example, userName() shows my local (Administrator) Windows username when I open Infopath XML data form from sharepoint form library of my Office 365 site.

    Shrout1:
    Web enable the form so that they are filling it out with their domain credentials

    This wouldn't enforce domain credentials since web enabled for can still be opened locally in client Filler with the same "local" username result:

    • this, through client/Filler form opening, seems to always happen with me when I create a new XML data form in form library in Internet Explorer 8 (Office 365/Sharepoint Online), while in Mozilla Firefox it is opened in browser
    • a user can opt to explicitly open an existing form in a Filler (instead of a browser) on local machine


     

     


    Gennady Vanin (Novosibirsk) --- Геннадий Ванин (Новосибирск)
Page 1 of 1 (12 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.