This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Error trying to edit object during BeforeSetObjectPermission event handling

Hello.

I have a following task: "if there were added a specific usergroups to permissions of object then to clear a field of this object."

I created an eventhandler for event BeforeSetObjectPermissions, it is successfully triggering on adding of usergroups, but I am unable to clear the fields of object. Looks like it is not allowed to make changes in objects during BeforeSetObjectPermissions event handling. I am receiving the error "Operation not allowed. Script is being executed for the object "48". (0x80040834)" at the row with CheckOut or SetProperty function.

Is there any way to solve this problem?

Thank you!

Parents
  • Hi Aleks,

    We have similar request and idea some while ago and have tried the same concept. Unfortunately this does not seem to work.

    At the end we have implemented auto workflow transition which checks periodically if (in our case) certain key employees have been changed and transition automatically to another workflow state where re-assign documents. The key is that in next state you are in separate transaction and you can do your action.

    I believe that you could use similar technique in you case: verify if usergroup has been changed (obviously you would need to keep track of used one and check if it is different from the new one, in our case we kept initial key employees as metadata on document so we could easily compared later) and when you transition in next step you do your reset (separate transaction). You can automatically navigate back to original workflow state so users would not experience anything.

    Perhaps it could help you.

    Dejan

Reply
  • Hi Aleks,

    We have similar request and idea some while ago and have tried the same concept. Unfortunately this does not seem to work.

    At the end we have implemented auto workflow transition which checks periodically if (in our case) certain key employees have been changed and transition automatically to another workflow state where re-assign documents. The key is that in next state you are in separate transaction and you can do your action.

    I believe that you could use similar technique in you case: verify if usergroup has been changed (obviously you would need to keep track of used one and check if it is different from the new one, in our case we kept initial key employees as metadata on document so we could easily compared later) and when you transition in next step you do your reset (separate transaction). You can automatically navigate back to original workflow state so users would not experience anything.

    Perhaps it could help you.

    Dejan

Children
  • Hi Dejan! Thnks for your answer! I am understand your idea and I tried to realize it for my task, but i found that any kinds of change permissions tracking at workflow state transition are triggering only at state transition from previous state or at checking-in of object. So if the object already have a current state and I change the permission only, it will not be triggered and the state transition will not be happen. I tried to use standard transition condition (available for edit to user/usergriups) and VBScript condition that sets AllowStateTransition = true and both of them are not working this way.

    You said you used some kind of transition that checks the condition periodically but I did not find a way to make such periodical checking. Could you please tell me how to do this? Thank you!

  • Hi Aleks, 

    It is a concept of automatic state transitions. You can read more closely here: https://developer.m-files.com/Frameworks/Vault-Application-Framework/Attributes/Workflows/#automatic-state-transitions.

    There are triggered periodically, default config is each hour but you can configure it run more often if you need.

    Inside of that transition, you would need to have your verification logic and in case it applies you would move it into next state where you make your metadata reset. Then you could configure transition back immediately back into original state and users would not experience the reset workflow state afterwards.

    Hope it helps you

    Dejan