In this post i will explain how XSLT can be used to hide the list columns in forms for users with insufficient previleges.
After you open your site and the list in SharePoint designer, create custom forms for New, Edit and Display forms.
Open each of the forms and select the column which should be shown based on user permissions.
Expand the Conditional Formatting option on the ribbon and select Show Content.
In the next screen click on Advanced.
In the pop up that appears after that, search for the function called IfHasRights
This function will determine whether the current user has the rights specified and will do the formatting accordingly, based on the result.
The permission mask specified is determined as the sum of the permission masks for the permissions required. Below mentioned are the permission masks for the permissions.
ViewListItems - 1
AddListItems - 2
EditListItems - 4
DeleteListItems - 8
ApproveItems - 16
OpenItems - 32
ViewVersions - 64
DeleteVersions - 128
CancelCheckout - 256
PersonalViews - 512
ManageLists - 2048
ViewFormPages - 4096
Open - 65536
ViewPages - 131072
AddAndCustomizePages - 262144
ApplyThemeAndBorder - 524288
ApplyStyleSheets - 1048576
ViewUsageData - 2097152
CreateSSCSite - 4194314
ManageSubwebs - 8388608
CreateGroups - 16777216
ManagePermissions - 33554432
BrowseDirectories - 67108864
BrowseUserInfo - 134217728
AddDelPrivateWebParts - 268435456
UpdatePersonalWebParts - 536870912
ManageWeb - 1073741824
UseRemoteAPIs - 137438953472
ManageAlerts - 274877906944
CreateAlerts - 549755813888
EditMyUserInfo - 1099511627776
EnumeratePermissions - 4611686018427387904
Give appropriate mask as shown in the screenshot above and save the form.
The next time the users open the form, they will see the column only if they have enough permissions.
Ofcourse you have to do the same to the label(Deparment) beside the text box you selected previously
This is how the form will appear for users who do not have enough previleges.
After you open your site and the list in SharePoint designer, create custom forms for New, Edit and Display forms.
Open each of the forms and select the column which should be shown based on user permissions.
Expand the Conditional Formatting option on the ribbon and select Show Content.
In the next screen click on Advanced.
In the pop up that appears after that, search for the function called IfHasRights
This function will determine whether the current user has the rights specified and will do the formatting accordingly, based on the result.
The permission mask specified is determined as the sum of the permission masks for the permissions required. Below mentioned are the permission masks for the permissions.
ViewListItems - 1
AddListItems - 2
EditListItems - 4
DeleteListItems - 8
ApproveItems - 16
OpenItems - 32
ViewVersions - 64
DeleteVersions - 128
CancelCheckout - 256
PersonalViews - 512
ManageLists - 2048
ViewFormPages - 4096
Open - 65536
ViewPages - 131072
AddAndCustomizePages - 262144
ApplyThemeAndBorder - 524288
ApplyStyleSheets - 1048576
ViewUsageData - 2097152
CreateSSCSite - 4194314
ManageSubwebs - 8388608
CreateGroups - 16777216
ManagePermissions - 33554432
BrowseDirectories - 67108864
BrowseUserInfo - 134217728
AddDelPrivateWebParts - 268435456
UpdatePersonalWebParts - 536870912
ManageWeb - 1073741824
UseRemoteAPIs - 137438953472
ManageAlerts - 274877906944
CreateAlerts - 549755813888
EditMyUserInfo - 1099511627776
EnumeratePermissions - 4611686018427387904
Give appropriate mask as shown in the screenshot above and save the form.
The next time the users open the form, they will see the column only if they have enough permissions.
Ofcourse you have to do the same to the label(Deparment) beside the text box you selected previously
This is how the form will appear for users who do not have enough previleges.
No comments:
Post a Comment