This InfoPath 2010 tutorial explains how to change to different views in InfoPath 2010 form based on a certain condition in SharePoint 2010.
Suppose an employee sends a leave request to a company. Then the request may go to the Team leader, HR, etc. So whenever an employee opens the InfoPath form he should see his information relevant to him, Similarly, the Team leader should see the relevant information team leader.
And a similar case with HR also. So in this type of scenario, we will create different views in InfoPath, one view for the employee, one for the team leader, and one for HR.
Follow the below steps:
1. Activate SharePoint server enterprise site collection features
2. Create the needed users
3. Create your custom list with following columns.
5. Now it will open your list in InfoPath form.
6. Now we will remove the unwanted columns – Title, Attachment, Action, State.
7. Click on PageDesign -> New view -> give the name of the view – Employee view, Team leader view.
8. Then copy the edit view and paste in your Employee view.
9. Keep the desired fields and delete the rest.
10. Add two button for submitting and cancel. Home->Control->Button.
11. Now do the same for manager view. Here three button- Approve, Reject, Cancel.
12. Then we will add rules for switching views.
13. Click on Data Tab -> Form load -> New -> Action -> Type Show employee view -> condition -> status is blank -> switch views -> Employee view. see fig below
14. Do same to show TL view. Only add the condition as status -> is equal to -> WaitingTL. see fig below
15. Now go to Employee view -> submit button -> New -> Action -> Give name as SubmitEmployee-> Add-> set field value:Action= SubmitEmployee -> submit data using data connection -> close the form
16. Cancel button -> new -> name :cancelemployee -> add -> close form
17. Go to TL view -> Approve button -> New -> name :ApproveTeamLeader -> set field value: ApproveByTL-> Submit data -> close form.
18. Do same for reject button only change the set field value as RejectTL.
19. Cancel button has the same rule as in Employee view.
20. Now save and publish the InfoPath form.
21. Now go to your list and add the new item. It will show you the employee view.
22. Here you fill in the details and submit.
23. Click on datasheet view from ribbon and change the status to WaitingTL.
24. Now come to your item. Click on the item it will show you the TL view. And here you can approve the employee.
You may like following InfoPath 2010 tutorial:
- Only date or date and time allowed InfoPath 2010/2010 error in SharePoint 2010/2013
- Change different view in InfoPath based on certain condition
- InfoPath designer repeating table example
Hope this will be helpful to change different views in InfoPath 2010 based on certain conditions in SharePoint 2010.
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SPGuides.com