You can simply hide the Views on the ribbon while you edit the form. Go to File tab > Form Options and uncheck View from the below option and then save/publish your form.
If you are looking for another approach without touching the above option, then in InfoPath Designer open:
- Click Data tab
- Click Form Load button
- Create a rule that switch views based on the currently login user where condition would be
CurrentUser == "Venkat Garikapati".
- You should create a field 'CurrentUser' that will control the view. This could be simple text field.
(CurrentUser would be a field that fetches the currently login user. You can implement this approach by code-behind where you will fetch the currently login user in store it in CurrentUser field).
Code-behind logic to fetch currently login user and update it on CurrentUser field:
public string currentLoginUser
{
get
{
string _user = HttpContext.Current.User.Identity.Name;
return _user;
}
}
This code will fetch saMAccountName along with the domain name. You should implement a logic to discard "\\" character from the name and fetch the display name from AD.
root.SelectSingleNode("/my:SalesFields/my:txt_CurrentUser", NamespaceManager).SetValue(userName1);
Above userName1 is the final display name fetched from AD.