Set List Item Permissions From Newform and Editform

Oct 4, 2011 at 4:13 AM
Edited Oct 14, 2011 at 3:59 PM

I am trying to develop a script to run in a CEWP on the newform and editform pages of a list item that will set the items' permission based on another field of the item. Example - the item is an activity associated with a sales office (North, South, East, West), users from each branch are in seperate AD Groups, only users from the same branch should see the activity. This is very easy in .Net but I cannot write .Net web parts at this client and do not have access to SharePoint Designer. I am also not aware of a web service to accomplish this.

MOSS 2007 Enterprise

Suggestions?

Thank you in advance!

Coordinator
Oct 4, 2011 at 3:17 PM

Chuck:

Take a look at the Permissions Web Service. I think it'll do it for you.

M.

Oct 4, 2011 at 4:40 PM

I'm pretty sure the Permissions Web Service has no method for dealing with 'list item' - only lists and webs.

Coordinator
Oct 14, 2011 at 1:54 AM

Chuck:

You are correct, sir. I was just trying to do something similar today, and I don't believe that it's possible with client side code.

M.

Oct 14, 2011 at 4:06 PM
Edited Oct 14, 2011 at 4:10 PM

The only possible solution I've come up with is:

1) use the Permissions Web Service to copy the current permissions of the list

2) Change the list permissions to be what is needed for the list item

3) Create the new list item. It will inherit the permissions that were just set on the list.

4) Change the list permissions back to the original values.

 

It's ugly but it should work. I'm working on a higher priority site right now but I'll get back to this and post the working code (assuming it actually works :) )

Oct 14, 2011 at 6:36 PM

Another approach might be to create four identical lists, one for each region. Users would only see the list associated with their group. Not sure what other factors might be involved to prevent this admittedly brute-force method, but thought that I would throw it out there. I appreciate how hard it is to develop solutions without any tools.

Good luck!

From: ChuckTPS [email removed]
Sent: Friday, October 14, 2011 4:07 PM
To: steve.eagleson@sky.com
Subject: Re: Set List Item Permissions From Newform and Editform [SPServices:274658]

From: ChuckTPS

The only possible solution I've come up with is:

1) use the Permissions Web Service to copy the current permissions of the list

2) Change the list permissions to be what is needed for the list item

3) Create the new list item. It will inherit the permissions that were just set on the list.

4) Change the list permissions back to their original values.

It's ugly but it should work. I'm working on a higher priority site right now but I'll get back to this and post the working code (assuming it actually works :) )

Oct 14, 2011 at 7:52 PM

@Chuck

Your solution will only work if your users have permissions to change permissions on that particular list.