0

Is it possible to "softlock" a SPListItem so that a user can't edit it but a workflow he had started can do it?

Background:
- ListItems should only be editable by users when no workflow is running
- Workflows should only be startable by users when no other workflows are running
- Workflows may change ListItems
- Users have to be notified why they can't start a workflow or edit an item anymore (not via Email)

My first idea was to set read-permissions for everyone for that item, so that they can't edit and start other workflows as long one is running, but the customer wants some kind of information for his users (like an error message but not an email). Since SPD Workflows are being used I am not able to show an error message or somehting. So what i did was implementing two event receivers. One firing when an workflow is starting (checking an invisible column 'ActiveWorkflow', showing up an error when the column has a value other than 0, which is set by workflows) and the second event fires when an item is updating (to prevent and abort changes that users make when a workflow is running). My problem with this approach is that i can't differentiate between user edits and workflow edits in the ItemUpdating event, thus blocking my own workflow.

Another idea that came to my mind was designing the whole workflow in an impersonation step and check the current user in the ItemUpdating Event (should be the account which published the workflow if the item was changed by workflow) but I don't really like this solution because all changes to this item will be made by this user (fields like modified by, etc) as far as I know and I need to change existing workflows in their structure, since the things I listed in the background are change-requests for existing, complex workflows and I want to change as less as possible because they are working as intended.

0

It can be done by javascript in different ways.

If you add a function PreSaveAction() to the page it will be called by the save button before the save, and here you can make your check if it's allowed to be edited.

Another simple way is to use validation on the formula.. something like

=IF([WorkFlow]='Yes', [HiddenDate]>NOW(), True)

then you can set the workflow and the hiddendate in the workflow to make the save valid.

I have made a blog on form manipulation that might give some hints. http://1001sp.blogspot.dk/2014/02/fun-with-sharepoint-lists-and-forms.html

  • Thanks for the hint with the PreSaveAction(). I was able to make the description unenditable but there is one problem left: the user is should not be able to check out the item and edit it. My first idea was to change the edit control block and remove the option to check out the item. Would that be the correct approach to reach my goal or are there better ways to accomplish that? – Razze Feb 19 '14 at 7:36
  • That's a good question.. If you remove it from the edit control block won't that work for all items?? I don't know if its possible, but I would try to see if I could hook up on the function that enables the checkout.. then it would work on both the ECM and the Ribbon.. I guess. – Burrhus Feb 19 '14 at 7:43
  • Good point with the ribbon, didn't think of that. I think disabling the function to check out will not help me, since workflows need to check out items to edit them. I'll give it a try to hide the check out ribbon & the check out option in the ecb. Thanks so far, you're a great help :) – Razze Feb 19 '14 at 7:59

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.