none
username() function not following current user on subsequent edits RRS feed

  • Question

  • I ahve an infopath (2010) form in a MOSS library that uses rules to determine if the current user is th manager, and disables controls with formatting rule if the current user is not that person.

    When I deployed this form and had the manager try it, the fields were disabled for her. So as a diagnositic I added a text box with the username() as default value to reveal. I found that for that user the name listed on her edit was the person who created the form. The manager noticed that she could change the value to her username and viola all the fields were suddenly enabled.

    I'm confused... how do I get the username() function to reveal the current logged on user automatically?

    /Robin

    Wednesday, February 23, 2011 5:15 PM

Answers

  • You can have a hidden field in the form (i.e. a field in the data source but without a text box or anything for users to enter data) that stores the value of the current user's username. Use this for your rules regarding whether or not to disable controls.

    To make sure this always has the appropriate value, add a new rule that runs when the form is opened. Go to the Data tab and click the Form Load button. This gives you a space to create rules that run every time someone opens the form. Create a simple action rule that sets the value of the hidden field to username().

    • Proposed as answer by Jessica Meats Thursday, February 24, 2011 8:58 AM
    • Marked as answer by RobinTheHood Thursday, February 24, 2011 1:01 PM
    Thursday, February 24, 2011 8:58 AM

All replies

  • add an expression (calculated) box.

    =userName()

    default is only set fist time. 


    jliu - johnliu.net - sharepointgurus.net
    Thursday, February 24, 2011 4:28 AM
  • You can have a hidden field in the form (i.e. a field in the data source but without a text box or anything for users to enter data) that stores the value of the current user's username. Use this for your rules regarding whether or not to disable controls.

    To make sure this always has the appropriate value, add a new rule that runs when the form is opened. Go to the Data tab and click the Form Load button. This gives you a space to create rules that run every time someone opens the form. Create a simple action rule that sets the value of the hidden field to username().

    • Proposed as answer by Jessica Meats Thursday, February 24, 2011 8:58 AM
    • Marked as answer by RobinTheHood Thursday, February 24, 2011 1:01 PM
    Thursday, February 24, 2011 8:58 AM
  • Many thanks John and Jessica for your suggestions! The form load did the trick! I set a value on form load for username() and viola works like a charm!

     

    /Robin

    Thursday, February 24, 2011 1:12 PM