Name of User - For Display - Form Creation - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Name of User - For Display - Form Creation

Last post 09-12-2014 02:34 PM by draghuna. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 09-11-2014 03:21 PM

    Name of User - For Display - Form Creation

    Infopath Form 2007 - I have a text field (read only) where I want to display the person who created the form. I was able to capture the accountId using username() function but it does not show the actual name of the person. I want to show something like "John Smith". - I used a hidden variable to capture the username and unchecked "Update this value when the result of the formula is recalculated". I wanted to make sure this value is the same throughout the life cycle of the form even if someone else is editing the form subsequently. Thanks
  • 09-11-2014 03:34 PM In reply to

    Re: Name of User - For Display - Form Creation

    First, generally instead of using a default value for something like this, I use a form load rule - and rule would be - if the field is blank, set it to the value (so it only gets set in a new form). I think you can use the SharePoint User Profile service for what you need - more here: http://blogs.msdn.com/b/infopath/archive/2007/03/07/get-the-user-profile-through-moss-web-services.aspx

    Hilary Stoupa

  • 09-11-2014 04:41 PM In reply to

    Re: Name of User - For Display - Form Creation

    I am stuck with step 4. It looks like you reference material is related with C# programming language. I dont have C#/VB on my machine. I am using JS for programmatic coding. Dont see the option to add a web reference in Script Editor. However, I was previously able to add the UserProfileService web service directly from the InfoPath form.
  • 09-11-2014 06:00 PM In reply to

    Re: Name of User - For Display - Form Creation

    Sorry, should have read through that more closely - I didn't intend to suggest a code solution. I thought in IP 2007 / ShP 2007 we could create a data connection to the UserProfile service and just use that for user info - not sure why that blog suggests using code to get the values.

    Looks like someone covers that in the comments on that post tho-

    Let's take it one step further and make it a no-code solution!  How?  Throw out steps 3 and 4.  Instead:

    3)  Create a new data connection to retrieve information from the specified web service (http://<yourServerName>/_vti_bin/UserProfileService.asmx?WSDL), and select the "GetUserProfileByName" web method.

    4)  Use an XPath query on your secondary data source to populate the fields you want.  For instance, use a formula to set the default value for an "email address" field.  You'll be selecting the "dataFields/.../Value" field.  The trick is to ensure you select the correct PropertyData node, as it is a repeating field - you'll have to edit the XPath to do so.  Assuming your secondary data source is called "GetUserProfileByName", the XPath query required to get the current user's email address looks as follows:

    xdXDocument:GetDOM("GetUserProfileByName")/dfs:myFields/dfs:dataFields/s0:GetUserProfileByNameResponse/s0:GetUserProfileByNameResult/s0:PropertyData[s0:Name = "WorkEmail"]/s0:Values/s0:ValueData/s0:Value

    Works beautifully, and without needing to bust out any code!

    Hilary Stoupa

  • 09-12-2014 02:34 PM In reply to

    Re: Name of User - For Display - Form Creation

    Appreciate the quick response and it solved the problem I was facing.
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.