1

I have a custom list. Is there a way to make it so when a user adds a new item they can, in the NewForm.aspx/EditForm.aspx page, specify who can view the item once it is created?

I know they can modify the permissions of the item after it has been created but is it possible to do it from the NewForm/EditForm?

Also, I can't create custom application code. I can only use, if needed, SharePoint Designer (including Workflows) and custom JS.

1 Answer 1

1

This can be done using a Designer WF and REST. The hard part is going to be if you need to allow multiple users to have access. Basically, you will need to add a field to your forms that you can enter the users. A people picker or text field will do. The text field can make it more likely that mistakes will occur, but I think will be easier to parse out multiple users.

The next thing you will need to do is create a new 2013 WF that reads that information and calls the rest service to BreakRoleInheritance and AddRoleAssignment. You are going to need to get the user's ID and the role definition ID. Doing this as a JavaScript file on the form would be easier, but since the item hasn't been created yet in the NewForm, you can't run it there, so your only real option is the WF.

There is a great explanation of the REST information you will need here: http://spsite.pro/Blog/Post/3/SharePoint-2013-REST-API-%E2%80%93-How-to-set-Unique-Permissions-%28Item-Level-Permissions%29

You can also get some great information on running REST from a WF here: https://sergeluca.wordpress.com/2013/04/09/calling-the-sharepoint-2013-rest-api-from-a-sharepoint-designer-workflow/

Hope this helps

5
  • Will this work with 2010? Feb 4, 2016 at 17:23
  • I am terribly sorry. I missed that you tagged this as SP2010. No this won't work as you can't call REST from an SP2010 WF. I honestly don't know of a way you can do this without a custom code WF in 2010. Again, you could do it from the javascript file, but it won't work in the NewForm because the item hasn't been added yet. If you are willing to trust users to do it, you could try a custom action that directs you to a page that you can load javascript files on and call REST from there. However, custom actions have to be manually activated. Feb 4, 2016 at 17:28
  • I can redirect from NewForm to a page that will have JS to find the ID of the last created item. And I think I figured out how to use JSOM to BreakRoleInheritance and AddRoleAssignment using the MSDN docs so I will try that tomorrow. Thank you sir! Feb 5, 2016 at 1:30
  • Thanks for your help sir! I was able t get this to work perfectly. sharepoint.stackexchange.com/questions/169313/… Feb 5, 2016 at 22:14
  • You're very welcome! Feb 5, 2016 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.