I have an InfoPath form with two views - one for viewing a SharePoint list items data (which only shows a few fields), the other for editing. What I want to do is to check if the current user of a SharePoint group, and if they have edit rights (i.e. they created the item). If they are in group 'X' and it is their list item, then allow the edit to take place (showing the extra fields). If not, prevent the edit form from showing (or show a form with readonly fields).
I can see that it is possible to add a connection to a web service (http://sharepoint2010/_vti_bin/UserProfileService.asmx), but how do you actually call the service before form load, i.e.
- Get current user
- Query Web Service for groups current user belongs to
- Get current list item 'Created By' user
- Show form 'A' (readonly) if user is member of group 'X' and 'Created By' is not the same as the current user
- Show form 'B' if member of group 'Owners' or 'Created By' is same as the current user
Any idea how I can go about this?
username() does not return the domain, just the username. Also
Created By is a person/group picker, how would you query that to get the AccountId (which is DOMAIN\username) to compare with the hidden field value?