Page 1 of 1

Make all field read only

Posted: 15 May 2014
by Kim Jeim
Hi,


Based on a 'Status' field, I want a group of users to "lose" their Edit Rights, i.e. all the fields in the Edit Form become read only. This 'Status' field is controlled by an Admin group with Full Control so I am not worried about tracking the change of this status.


How do I do this without calling every single field individually? There are quite a lot of fields.


Many thanks in advance.

Re: Make all field read only

Posted: 16 May 2014
by Dmitry Kozlov
I'd recommend to use groups functionality that allows you to create completely different forms for SharePoint groups or field values (Status in your case). Please, watch the following video that demonstrates a similar case:

http://www.youtube.com/watch?v=SBLD9hXr19o

Re: Make all field read only

Posted: 16 May 2014
by Kim Jeim
Hi Dmitry. Thanks for getting back to me! I would like to, but the organisation wants it so that for that particular group the permissions are as follows:


1) Contribute rights if Stage = 1, and part of that permission group

2) Read Only rights (still able to see the form), if Stage is > 2, and part of that permission group


So even within that one permission group, the permissions change depend on the stage of the list item. Open to ideas on how you think this can be done elegantly. There are 8 separate groups, and they are called division in this organisation.

Re: Make all field read only

Posted: 16 May 2014
by Kim Jeim
Hi Dmitry, I figured out an easier way to do it. Thanks for the response. What I did was use the user-defined rule to determine if the user could get Edit Rights (quite a complicated IF statement, but a much more elegant solution than what I had in mind originally).


I then made all the fields Read Only in the form that All Users get.

Re: Make all field read only

Posted: 18 May 2014
by Dmitry Kozlov
Exactly! Good job, Kim.

Re: Make all field read only

Posted: 18 May 2014
by Kim Jeim
Hi Dmirty, I have not gotten this function to work: IsCurrentUserMemberOfGroup();



For example, just as a simple case, if I set the user-defined rule to be

IsCurrentUserMemberOfGroup('Executives'), it is seen as valid, but an Executive cannot see the special form I designed (I made sure the priority is high for this group).


Am I using this function correctly? Because I need to expand this for the example I had earlier, where if you were part of 1/8 divisions (SP permission group), the line item belonged to that respective division (choice field), and the status of the item was in "Stage 1", I have a particular set of forms that allow me to edit, if not I get the All User set of forms which are read only. This is what I use as my user-defined rule (but all I get is the All Users Read only form):


[Project Status] == '01-Planned - Not Approved' && (

([Division] == 'CRD' && IsCurrentUserMemberOfGroup('Division CRD')) ||

([Division] == 'DVD' && IsCurrentUserMemberOfGroup('Division DVD')) ||

([Division] == 'ERD' && IsCurrentUserMemberOfGroup('Division ERD')) ||

([Division] == 'SSD' && IsCurrentUserMemberOfGroup('Division SSD')) ||

([Division] == 'NS&ID' && IsCurrentUserMemberOfGroup('Division NS&ID')) ||

([Division] == 'MED' && IsCurrentUserMemberOfGroup('Division MED')) ||

([Division] == 'CSD' && IsCurrentUserMemberOfGroup('Division CSD')) ||

([Division] == 'DCEO' && IsCurrentUserMemberOfGroup('Division DCEO'))

)


Thanks in advance.

Re: Make all field read only

Posted: 18 May 2014
by Kim Jeim
Hi, just to add. I tried to print the value of IsCurrentUserMemberOfGroup('Executives') to the console, and it said the function is undefined. I found the function in one of your pages: http://spform.com/documentation/groups/functions. Not sure what I am doing wrong. I basically need to check if the user is part of that SP permission group.

Re: Make all field read only

Posted: 19 May 2014
by Dmitry Kozlov
Hi Kim,

You cannot execute this code in the browser console because it isn't JavaScript. This code is executed on the server side. For example, IsCurrentUserMemberOfGroup has the following body in C#:

Code: Select all

var group = Web.SiteGroups[groupName];
return group.ContainsCurrentUser;
Your code seems correct. Please, try to define less complicated rule with IsCurrentUserMemberOfGroup() only. Make sure that you don't have misprints in the name of SharePoint group and the user belongs to it. I've just tested this function in my environment. It works properly.

Re: Make all field read only

Posted: 19 May 2014
by Kim Jeim
Hi Dmitry,


I have tried what you suggested, and just used Administrators as the group I am checking against as it is a simple out of the box SharePoint group. It still does not work. I attached a video to hopefully help: http://screencast.com/t/JjCJPcJgdJL


I think (and I may be wrong), that it was working the way I expected it to last week when I replied to you saying I figured it out. That is why I am so bewildered as to why it is not working. Also, some additional information, I am using Forms Designer in a SaaS EPM Live environment.

Re: Make all field read only

Posted: 19 May 2014
by Dmitry Kozlov
Please, note that the function IsCurrentUserMemberOfGroup has been implemented in version 2.8.4. If you have an earlier version, please download the latest one from our website and upgrade your current version: http://spform.com/download