1

What is the best solution for such requirements?

  • Allow users to add items to list from custom webpart
  • Prevent same grp of users to view/edit items directly from list
  • I cannot use elevated privilege to add items from webpart as when a new item is added i will need to trigger workflows.

We are preventing users from editing the list directly as they are only allowed to enter data through a custom webpart. This is to secure integrity of data. These data once submitted should not be touched. This data will be run through a list of workflows for approval.

Thanks in advanced!

  • can you explain why they cannot view or edit directly? If they have access to the list, they can navigate to it,correct??? so maybe if you explain the reason behind your requirements, I can provide you with the answer!!! – Ahmed Mahmoud May 24 '16 at 3:16
  • @AhmedMahmoud hey edited my post. hope its clearer now. thanks – codeandfootball May 24 '16 at 3:23
3
  1. Allow users to add items to list from custom web part - On default new form put a script to navigate to page which says - "New item cannot be added from here" or alternately add content editor on new page with text " New item cannot be added from here" and hide (not delete) the existing web part on page

    1. Prevent same group of users to view/edit items directly from list - For edit follow above process. For view either create default view with specified columns

    2. I cannot use elevated privilege to add items from web part as when a new item is added i will need to trigger workflows. - The issue you have with using RWEP is that created and modified will be set as 'System Account", the solution to that is update "Created" and "Modified" as current user. Take current user before starting of RWEP. This way workflow should trigger as current user not system account.

  • Thanks for your reply. Do have a look at the solution i posted to see if you have any opinions. Thanks. – codeandfootball May 26 '16 at 1:57
1

Remove the NewForm and EditForm from the list. This way nobody can create or edit list items.

  • How do we remove those forms? And also is there a way to disable/enable those fields instead of directly removing? – codeandfootball May 24 '16 at 3:44
  • You can open the list in SharePoint Designer and edit/remove the forms. For disabling fields easiest option is using JavaScript. Best option is to use CSR. You can recreate these forms anytime with a single button click from SPD. – Amal Hashim May 24 '16 at 3:45
  • I see. Say if I want to delete through SP Designer, how do I go about deleting this form? Is it through 'All Files -> List' ? I tried this way, but it is still listed under 'Forms' of my List. – codeandfootball May 24 '16 at 4:02
  • Its ok. Managed to remove the forms. Will need to look into disabling the fields. Else user will see it as enabled, but server error when clicked. – codeandfootball May 24 '16 at 4:11
  • Hey do have a look at the solution i posted to see if you have any opinions. Thanks. – codeandfootball May 26 '16 at 1:57
1

Here's the deal.

  • You can create a default view with access to only a specific user group. There are ways to implement this.
  • Also, from all views, remove link for new item and remove column with context menu. Additionally you can put some javascript to not allow advance ribbon except admin group or something.
  • Alternatively. You can put some javascript to validate if user is not part of your XYZ admin. If he is admin, let me open the default form/list/views, else redirect to your custom webpart page.
  • Removing default form would create mess in case if some changes are expected from backend (direct to list).

Another best approach would be Let the default form be there. Just open those in edit mode. Open webpart properties of default webpart. Set target audience to a specific group.. lets say admin group. Now below that add your custom webpart with no audience target. this will lead the user to your custom webpart even if he clicks default links.

  • For the default view, can we ensure that other user groups will not have access to other views? Remove link for new item seems easiest at the moment. How do I go about doing this? – codeandfootball May 24 '16 at 4:03
  • @juniordeveloper87 See updated answer with another new approach – Gaurravs May 24 '16 at 5:42
  • Thanks for your reply. Do have a look at the solution i posted to see if you have any opinions. Thanks. – codeandfootball May 26 '16 at 1:57
0

Thanks guys for your ideas.

In the end, I decided to go with the following approach:

  • Remove all permissions from any user for the specific list.
  • Create another user account for impersonation purposes.
  • Give this new user contribute rights to the specific list.
  • Web part will impersonate this user account during submit. This will ensure that the workflows can get triggered as this is not a 'System Account'.
  • Publishing workflows using this newly created user account. Workflows are also added an impersonation step which will add 'Read' rights to the current item in list. This is required as this will give user access to the workflow task.

This approach ensures that user will not have edit/delete rights (the 'New Item', 'Edit Item', 'Delete Item' buttons on the ribbon are disabled automatically due to no permissions) to the list hence securing the list data integrity. User will only be able to submit their data through the webpart.

Feel free to share your opinions on this solution. Thanks.

  • Created and Modified field will be displaying "new user" name and not the actual user who did the operation. – Monica Jagani May 26 '16 at 4:37
  • @monica yeah. We will be using separate columns for that purpose. To store user in context who submitted. – codeandfootball May 26 '16 at 4:42
  • ok then that should work fine. – Monica Jagani May 26 '16 at 5:17
  • @MonicaJagani Great to hear! Thanks for your input! – codeandfootball May 26 '16 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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