Saed Al Shaar Dev Tips and Tricks

.NET and SharePoint from a different angle!

InfoPath 2007 – MultiView Web based Forms based on Simple Roles


Hi Folks,
Lately, I have been searching for a solution for one of my InfoPath forms where I need to have different view for the person who fills the form at the first time, and another for the Admin of the form.

The issue is that InfoPath 2007 and 2010 does not support a wizard based functionality to check the current user and it’s groups and comparing them with the SharePoint or AD groups, and User Roles is not supported in InfoPath Form Services.

I have checked many good articles talking about using WSS Web Services to retrieve the User Groups and many other complicated stuff, but I don’t like to comlicate things up.

Well, I have thought in a different direction, where I can create my own simple roles as I will explain here:

1- I have an InfoPath Form published on SharePoint document library, with 2 views, the default and Hidden views.

2- I created a sharepoint List named Admin with one column named UserName, and added the user name accounts for the administrators.

3- You need to create a Data connection to the list, if you don’t know how here is a link to do so:
http://office.microsoft.com/en-us/infopath-help/add-a-data-connection-to-a-sharepoint-document-library-or-list-HP010093160.aspx#BM3
You just need to read the part of “Add a query data connection”, at the end you will have a data connection to the Admin list.

4- In the InfoPath form, go to ToolsForm Options — choose Open and Save from Category pane.

5- Click on Rules button, and the Add button to add new rule.

6- Click on Set Condition button on Rule diagram.

7- Then from the drop down menu chose “Select a field or group“.

8- Then Select a Field or Group dialog window will open, chose the Data source for the Admin List, then chose the column name (UserName), and from the Select dropdown chose “Any occurrences of UserName“, then Click OK button.

9- Then, chose “is equal to” , and chose “Use a formula“, a chose the formula “userName()“.

10- Then click on OK button, and now we need to add an action to swith the view named “Hidden” as per the following illustration.

That’s it!

Now, whenever a user from the Admin list open the Form, it will switch to the view named Hidden.

Happy InfoPath-ing!
Saed

Advertisements

Single Post Navigation

2 thoughts on “InfoPath 2007 – MultiView Web based Forms based on Simple Roles

  1. Dear Saed!!!

    Your article helped m, I have resolved my problem!

    I have “Performance Appraisal Form” and don’t want user (not current user) to have permission to view created form.

    As I have InfoPath2010 (not 2007 as you) there is no “Open and Save ” button.

    That’s why I used “Form Load” rules.

    I added to your rule addition my rule:

    – if “Any occurrence of DisplayName” is not equal UserName() AND
    – if “Name Surname” is not blank

    Action: Switch to view: You don’t have permission

    “Dear User!
    You don’t have permission to view this Performance Appraisal.

    Please contact to …………………… for additional information.”

    I used your idea!))))

    Thank you very much for this item!

    Much obliged.

    Rena Huseynkhanova
    ISO 9001:2000. Lead Auditor ;
    ISO 27001:2005 and ISO 19011:2011;
    SharePoint 2010 Overview for End Users (No 50352);
    SharePoint 2010 SharePoint Designer (No 50354);

  2. Hello Rena,
    I am happy it works with you!!
    You’re most welcome.
    Cheers
    Saed

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: