Forum Discussion
Former_Member
8 years agoAccelerator III
Ok, got it to work, however, not as I had expected.
In an onBeforeUpdate event, adding the permission to the "this" object did not work reliably. Because if the user who is making the edit does not have the permission to change the permission, an error will be thrown and the Part won't be saved.
In an onAfterUpdate event, adding the permission to the "this" object doesn't accomplish anything. Instead I tried with an elevated AML update operation, where I tried to set the permission of the object. However, that did also throw an error. This time a strange one that I did not understand. However, I believe it due to the update operation causing an infinite recursive loop. I.e., updating a Part triggers its onAfterUpdate server event, which tries to update the same Part with a new permission, which triggers the onAfterUpdate server event, and so on. That is my theory at least.
So what I did instead was to make an SQL query from the onAfterUpdate server event. In the SQL query, I simply set the permission_id value in the PART database table. That did indeed work.