InfoPath Query to get User Name - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

InfoPath Query to get User Name

Last post 05-11-2017 05:16 AM by veney. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 05-08-2017 12:28 PM

    • veney
    • Not Ranked
    • Joined on 09-11-2009
    • Posts 14

    InfoPath Query to get User Name

    Based on a condition (i.e., modified by is not equal to user name)  can I create an InfoPath query to get the User Name from the user and save the form file via User name?


    Thanks in Advance,

     

    - Rodman 

     

  • 05-09-2017 09:40 AM In reply to

    Re: InfoPath Query to get User Name

    Hi Rodman

    I generally have a number of 'control' fields which are always hidden in a section at the top of my IP and Browser forms.  In fact I use a text field with two buttons - Hide and Show - to control their visibility when I am designing/testing the form as it makes it easy to see the values in the fields. 

    One bunch of fields relates to the User who has opened the form.  I have a Form Load event which drags into the fields a bunch of details including the UserAccount, UserName, UserEmail, UserManager, UserID and UserFirstLastName.  All of these are based around a Data Connection which is the GetUserProfileByName webservice.  The UserFirstLastName is a concatenation of the two separate values with a ' ' (space) in between.  This is particularly useful when you have a value in a lookup field where you can use the 'contains' element as part of a condition for an action or making a button visible or hidden.

    I do use the 'contains' a lot in preference to 'is equal to' especially with names as what appears in the UserAccount or as a UserName sometimes includes AD or other network information.

    Creating all of the User....  fields and values can be a bit of work to start with, however once they are on the form, you can be certain that every time the document opens it will compute the correct value for use.

     I hope the above helps.  Please advise if you have any questions. 

  • 05-09-2017 10:22 AM In reply to

    • veney
    • Not Ranked
    • Joined on 09-11-2009
    • Posts 14

    Re: InfoPath Query to get User Name

    merley72,

    Thank you for your quick response!

    The information you provided helped, however; my problem is a little more complicated than I initially described.  I am working on a better description (and solution).  I will provide the description at a later date/time.

     

    Again, THANK YOU! 

    - Rodman 

  • 05-09-2017 11:18 AM In reply to

    • veney
    • Not Ranked
    • Joined on 09-11-2009
    • Posts 14

    Re: InfoPath Query to get User Name

     Hi merley72,

     

    I have had time to develop a better description of my problem/issue:

    From SharePoint, an engineer clicks their InfoPath form which the GetUserProfileByName web service is used to get the name of the engineer.

    The engineer form is displayed with the name of the engineer and is completed by the engineer.  Once complete, the engineer submits the form/data to SharePoint, via the Submit button.  The Submit Data Connection concatenates the Engineer’s name with some text. 

    Using a different view, a manager can update the Engineer’s data in the event he/she is not available, provided the wrong information, etc.   However, when the manager accesses the engineer’s form, the manager’s name appears in the Engineer name field. I would like to change this behavior.

    As a work around, I display the name of the person who last modified the form (usually the engineer).  The manager then copies and pastes that name in the Engineer name field and clicks the submit button.  Via the Submit Data Connection, the form is submitted with the engineer’s name (not the manager name).

    If the manager forgets to change the engineer’s name, the form is submitted with the manager’s name and the engineer’s data.

    I would like the form to always present the name of the user who created the form and submit via that name, regardless of the view.

    Can this be done?

     

    Thanks in Advance,

     

     - Rodman 

  • 05-09-2017 01:47 PM In reply to

    Re: InfoPath Query to get User Name

     Hi Rodman, thanks for the extra information and I see the problem.

    Completing a step in a process and 'cheating; the system to act as someone else is particularly complicated I believe.  The last person to work on the form will (should? ) always be the person whose name appears in the 'last modified' field.  However....   would it not be possible to create a single field as a Document Number field, which gets created with the Engineers name when the document is first created and from that point onwards is always used as the name by which the document is saved?

    If this approach was adopted, whomever needed to work on the document could do without a change of document name.  I've used this method several times before for documents such as Training Records, Change Requests, Action Items etc. 

    Basically the same 'Save' data connection can be used, with a step in that which checks if there is a value in the DocumentNumber field and if there is, then it doesn't recalculate the file name.  In conjunction with that, I've used a text field which I've called 'NewDoc' which has a value of '1' assigned to it upon the first save,  With that in place all manner of checks can/don't need to me made.

    Please come back with further questions etc.

    Regards,  Alan C.

  • 05-10-2017 06:52 AM In reply to

    • veney
    • Not Ranked
    • Joined on 09-11-2009
    • Posts 14

    Re: InfoPath Query to get User Name

     Alan,

     Again thank you for your quick response.

    I will experiment with your solution on a test from and evaluate the results.

    Again, Thank You!

    - Rodman 

  • 05-10-2017 01:04 PM In reply to

    Re: InfoPath Query to get User Name

    Hi Rodman,

    Let's call the text field that houses the Engineer's name is txtEName.

    When GetUserProfileByName runs, we check txtEName field.

    If txtEName is blank then place the FullName from Getuser to txtEName; otherwise, just don't do anything.

    Logic behind: When Engineer creates the form, the txtEName must be blank so the txtEName will be populated with the FullName from GetUser. When the Supervisor or someone else looking at the form after being submitted, the txtEName would be no longer blank; therefore it would not update to the new FullName from the GetUser.

  • 05-11-2017 05:16 AM In reply to

    • veney
    • Not Ranked
    • Joined on 09-11-2009
    • Posts 14

    Re: InfoPath Query to get User Name

    Nathan, 

    Thank you for your input.  I will use this information to investigate/experiment on a similar InfoPath test form.

     Again - THANK YOU for your help/input!

     - Rodman 

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