Microsoft 开发人员网络 >
论坛主页
>
SharePoint - InfoPath Forms Services
>
InfoPath and SharePoint is there a way to check if a form is valid without creating a rule for every field
InfoPath and SharePoint is there a way to check if a form is valid without creating a rule for every field
- One of our developers is working on an InfoPath form that submits to a SharePoint form library. The form has 3 views Normal View (for filling out), Read Only View, and Manager's view (has all the form fields as read only but also has a Approve button at the bottom).
The form should function as follows:
1. User fills out the form
2. If the form is valid the form should submit
3. The form, after submission should open as Read Only, unless you are that user's manager
4. If you are the manager the form should open in a Manager's View so you can click approve button
Our problem is that we can't figure out how to check if the form is valid so we can switch the view to read only before the submit (so it saves the form as being on the read only view) . The check for Manager's View, where we check to see if current user = submitting user's manager, happens in the Tools > Form Options > Open and Save section.
答案
- That's not how you manage views. Switching to a view before submitting does not make the form open in that view the next time it's opened. That's really only when previewing the form. What you need to do for the views is set some rules in the Tools > Form Options > Open and Save tab that checks the identity of the user and then switches the view accordingly. If the user is not the submitter's manager, then go to the read only view. If the user IS the submitter's manager, then go to the Manager's view that has the approve button (and any other editing capabilities). To be even more efficient, you can just have a single read-only view that has an approve button that is either hidden or disabled if the current user is not the Manager. That method works if the manager ONLY has a button and isn't able to edit any fields, because that way you can set that view to Read-Only in the view settings (sets all fields to read-only but not buttons). You would still set a rule in Form Options to switch to the read-only view, but the condition could be that the form has been submitted by using any sort of hidden field that is checked when the form is submitted (many ways to do it).
To give you some ideas on how to do all this, including how to verify the user's manager, check my blog entries:
InfoPath – Get user information without writing code (extended) (getting Manager info and using it)
User Roles in Browser-Enabled InfoPath Forms (use the above concept of getting the Manager and apply it to the conditional formatting concepts here - no need for a contact list in this case, though)
SharePoint Architect || My Blog- 已标记为答案Xing-Bing Yu - MSFT 2009年7月10日 7:20
全部回复
- That's not how you manage views. Switching to a view before submitting does not make the form open in that view the next time it's opened. That's really only when previewing the form. What you need to do for the views is set some rules in the Tools > Form Options > Open and Save tab that checks the identity of the user and then switches the view accordingly. If the user is not the submitter's manager, then go to the read only view. If the user IS the submitter's manager, then go to the Manager's view that has the approve button (and any other editing capabilities). To be even more efficient, you can just have a single read-only view that has an approve button that is either hidden or disabled if the current user is not the Manager. That method works if the manager ONLY has a button and isn't able to edit any fields, because that way you can set that view to Read-Only in the view settings (sets all fields to read-only but not buttons). You would still set a rule in Form Options to switch to the read-only view, but the condition could be that the form has been submitted by using any sort of hidden field that is checked when the form is submitted (many ways to do it).
To give you some ideas on how to do all this, including how to verify the user's manager, check my blog entries:
InfoPath – Get user information without writing code (extended) (getting Manager info and using it)
User Roles in Browser-Enabled InfoPath Forms (use the above concept of getting the Manager and apply it to the conditional formatting concepts here - no need for a contact list in this case, though)
SharePoint Architect || My Blog- 已标记为答案Xing-Bing Yu - MSFT 2009年7月10日 7:20

