Need help with... Get Current User (No Code) - InfoPath Dev
in

InfoPath Dev

Need help with... Get Current User (No Code)

Last post 11-22-2013 08:10 AM by Hilary Stoupa. 12 replies.
Page 1 of 1 (13 items)
Sort Posts: Previous Next
  • 11-08-2013 11:23 AM

    Need help with... Get Current User (No Code)

    I am trying to pull in the name of current user

    I would normaly use ADWS to do this but the client dosn't have it.  So I'm using the following blog but to no avail. 

    http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx

    Attached is an example form.  Can anyone tell me what I am doing wrong.  I know I'm missing something really simple.

    Info:

    SharePoint 2010 Ent, Infopath 2010, brouser based form Security level set to Auto, no cert.

  • 11-08-2013 11:31 AM In reply to

    Re: Need help with... Get Current User (No Code)

     Here's how I usually debug this sort of thing.

    1. Drag the query fields and data fields from the GetUserProfileByName data source onto your form
    2. Add a button that queries that data source
    3. Preview the form - are you getting any data back?
    4. Enter a value in the query fields Account Name field and click the button that executes the query - are you getting any data back?
    5. If you are getting data back, is FirstName one of the fields?

    I'd warn you against using a default value for this information in your main data source. If the query executes on load, the field will be reset to the name of whoever opened it - works great if that's what you are intending, but it is usually not what people mean to do....

    Hilary Stoupa

  • 11-08-2013 01:08 PM In reply to

    Re: Need help with... Get Current User (No Code)

    actualy that is what I am intending.  I need a field that shows who opened the form, then I have rules based on that information.  And thank you for your guidence.
  • 11-08-2013 03:27 PM In reply to

    Re: Need help with... Get Current User (No Code)

    Hilary, yes the query is pulling in the FirstName. See the screen cap attached.


  • 11-08-2013 03:34 PM In reply to

    Re: Need help with... Get Current User (No Code)

     xdXDocument:GetDOM("GetUserProfileByName")/dfs:myFields/dfs:dataFields/tns:GetUserProfileByNameResponse/tns:GetUserProfileByNameResult/tns:PropertyData/tns:Values/tns:ValueData/tns:Value[../../../tns:Name = '"FirstName"']

    I just realized, you have too many quotes around FirstName. You want just "FirstName"

    Hilary Stoupa

  • 11-08-2013 03:42 PM In reply to

    Re: Need help with... Get Current User (No Code)

    see it was something stupid I missed.  Thank you!  It's nice to know that the light at the end of the tunnle is you and not an on coming train!  :)
  • 11-08-2013 03:48 PM In reply to

    Re: Need help with... Get Current User (No Code)

     Hah - well I should have caught it prior to making you drag a bunch of debug stuff onto your form and PROVE that FirstName existed. :) Have a great weekend!

    Hilary Stoupa

  • 11-18-2013 12:00 PM In reply to

    Re: Need help with... Get Current User (No Code)

    Hilary, I've run into one more issue on this.  I get an authentication error when trying to open the form on the server.

    I check the SharePoint event log and I see this... Server was unable to process request Attempted to perform an unuthorized operation.

    So I created a test form with a single field "EmpName".  Created a data connection to the GetUserProfileByName.  Converted the data connection in InfoPath to a Connection File and saved it to my Data Connection library on SharePoint.  Approved the Data Connection in the library.  

    Still get the same error. 

    The form has been uploaded as a content type. The forms security is set to Automatically Determain, there is no certificate attached to the form.  The site  is using  NOT https and SharePoint is using Claim Based Authentication. 

    Also I have gotten this process to work in the past and on my test dev environment with no issues. 

    Hilary any help you can give me would be appreciated.  I have never ran into this many issues with publishing a form. 

  • 11-18-2013 02:36 PM In reply to

    Re: Need help with... Get Current User (No Code)

    Is your data connection executing on load? I would set it to not do that. I'd drag the query field onto the form and add a button that executes the query. I'd put some data fields on the form too so I'd know if I got anything back. Then add a calculated value on the form with the userName() function as the value. Publish, and open in the browser. Now you can see what your userName() is according to the claims enviro - try pasting the value in the calc'd value into the query field and executing the data connection to see what you get....

    Hilary Stoupa

  • 11-18-2013 02:52 PM In reply to

    Re: Need help with... Get Current User (No Code)

     Hilary, thanks for the response...  I'm not sure how this relates to the data connection throwing a permissions error, sorry I'm confused.  The data connection works fine (returns the users name) when in design mode, it only throws an error when opening the form after it has been published.

  • 11-18-2013 03:03 PM In reply to

    Re: Need help with... Get Current User (No Code)

     Does it return data in the browser? Is the error occurring when the data connection executes?

    When you open in filler, the user profile web service is going to work w/ your user name from Windows - jsmith, whatever. But then, in the browser, it wants your claims user name.... And that isn't what's being passed to the data connection.

    Hilary Stoupa

  • 11-22-2013 07:45 AM In reply to

    Re: Need help with... Get Current User (No Code)

    Hilary, I thought I might update you on the situation.  After doing what you suggested I did indeed find out that what you mentioned above was happening.  It's because I built the site for the client using claims based authentication in an attempt to ease things when eventually upgrading them to 2013.  This is causing no end of issues with my forms.  So I ended up calling Microsoft to see if there was a work around. We attempted using creating a new secure store entry for the forms but that didn't work.  I'm still working with them on this.  I wanted to thank you for pointing me in the right direction.  As always I much appreciate your help and the help of your company.

  • 11-22-2013 08:10 AM In reply to

    Re: Need help with... Get Current User (No Code)

     You bet - when you get things resolved, please update the thread so that others can benefit. :)

    Hilary Stoupa

Page 1 of 1 (13 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.