username() on subsequent openings of an infopath 2010 form - InfoPath Dev
in

InfoPath Dev

username() on subsequent openings of an infopath 2010 form

Last post 05-11-2011 02:32 PM by TobyHosterman. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-10-2011 01:30 PM

    username() on subsequent openings of an infopath 2010 form

    I have an infopath 2010 filler form that uses a multi-step process where one person fills it out initially then sends to someone else to add their pieces and so on maybe 3 or four times total.

     I was hoping to rely on username() executing each time the form is opened to compare the userid against some roles I defined in the form to know who's logged in and to tailor sections hiding/showing and fields enabling/disabling based on role membership.

    I'm finding that the username() function works great the first time the form is filled out; I save that to a field (FirstUserName) just fine.  Then the form is submitted via email to the next person in line.  When that person opens the form, username() seems to run fine but won't populate any fields (like SecondUserName), leaving the user stuck in the default role.  I know that username() is running because I configured a rule on Form Load that "displays the value of a function" (username()), and it shows the current user name every time.  But that same rule tries saving the value of username() into another field (SecondUserName, for example) for permanent keeping, and that field is always showing just a blank value.

     Anybody seen this before and overcome it?

    Any help would be much appreciated!

    Thanks!

    Toby

  • 05-10-2011 10:07 PM In reply to

    Re: username() on subsequent openings of an infopath 2010 form

    Hello Toby,

     Could you attach some screenshots of how your rules are set up?  It should definitely be possible to do what you're describing.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-11-2011 06:24 AM In reply to

    Re: username() on subsequent openings of an infopath 2010 form

    I define the role of "employee" using the InfoPath "User Roles" gui feature as, "User names from the form" and selecting a "EmployeeUserID" field from my main datasource in which I store the username() function the first time the form is opened, On Form Load.

    I use a SOAP web service that takes EmployeeUserID as a parameter, executes a SQL stored procedure with EmployeeUserID as a parameter, and returns a bunch of fields about the employee such as their manager's name and userid and other personnel-type data.  Another rule that runs after the "set employeeUserID" rule, retrieves the employee data from this web service and sets the results into a bunch of main datasource fields.  This rule only runs when the employee section data is "not signed",  and the employee section fields are signed just before the employee user submits the form.

    The form is able to do all of this just fine.  When the "employee" user is finished filling out the form, they click a button that submits the form via email to their manager's email address.

    The problem comes in when the manager opens the form.  I have the "manager" role defined as, "user names from the form" and selecting the "SupervisorUserID" field from my main datasource.

    My problem is that the manager is not identified in a role, so they fall into a "Undefined" role I created that's the "default" role but has no definition to it.  To troubleshoot this, I added the EMployeeUSerID, SupervisorUserID, and CurrentUserID fields to the form.  I populate the CurrentUserID field, which is NOT within any digitally signed sections, on form load always (no conditions on that rule's execution) by just populating it via a rule with username().  The form always shows this field as empty.  To troubleshoot further, in that same rule that populates the CurrentUserID field, I added an action that displays the value of a function, username().  Each time the form opens, a window pops up showing the current userid perfectly.  But then, the CurrentUserID field is still empty on the form, and the role is still Undefined.

    What screen shots can I email to you? (since I don't believe this forum supports inserting images directly, and I don't have a means for posting them publicly to hyperlink to)

  • 05-11-2011 09:00 AM In reply to

    Re: username() on subsequent openings of an infopath 2010 form

    It sounds as if something else may be clearing CurrentUserID. Can you use the Rule Inspector on that field, see if anything else may be changing it? Can you change your rule where you are troubleshooting to also show the value of the CurrentUserID field, right after you set it to the result of the username function?
    Hilary Stoupa

  • 05-11-2011 02:32 PM In reply to

    Re: username() on subsequent openings of an infopath 2010 form

    You were right.  I had something resetting the field.  Works great now, thanks!
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.