Search code examples
infopathinfopath2010infopath-forms-services

How to ensure that the username that is auto-populated does not get replaced by another one in InfoPath


I have an approve and reject form having three views. In the first view i.e the requester's view I auto-populate the requester name by using "GetUserProfileByName". Now I also want to auto populate the name of the user who approves the form in a different view (but this view also has the requester's name)- so I was wondering if I actually use "GetUserProfileByName" again won't it change the first name too (i.e the requester's name). I don't have other accounts to test it out.

Can someone please provide a workaround to this problem

So basically I want this to happen:- For example when John enters the form his name should be auto populated in the requester's name field. And once this form is send to Michelle who approves it - the approver's name field should have been autopopulated with Michelle's name.

How can I avoid overwriting of data.

Thank you for helping


Solution

  • Add fields to the form data source to store the data returned from GetUserProfileByName service. Do not use default values for the values in these fields. Instead, I generally use form load rules for this - run the query, and then, if the requester field is blank, set the field to the user's name from the datasource.

    When the approved view is submitted, you can take a similar approach with the approver name field - if it is blank, set it.