Locking certain records from being modified

Hello,

I've got a small problem, I need to lock certain Transfer Orders documents from being able to be modified by anyone.

I've added a "Locked" boolean field in 'Transfer Header' table that I want to use to achieve that. I've added some code in the OnModify trigger from the Sales Header table that checks if the Locked field is true, if that's the case I'll throw an error.

My problem is that the trigger isn't run until I move to another record ( in this case the Transfer Lines from the card page ).
Ex. I can modify all fields from the header and then click in the lines part of the page, only then will the OnModify trigger run and I'll receive the error. Upon refreshing, only the last field modified would go back to the initial value.

Is there a nice way of doing this? I can surely add the check for all OnValidate triggers but that would be a bit sad.

A bit of context, I'm displaying a codeunit as a web service, in the codeunit there's a function that sets the Locked field to TRUE or FALSE.
That's the only method of locking/unlocking a record.

I would highly appreciate any help! Sorry if this seems like a dumb problem.

Answers

  • David_SingletonDavid_Singleton Member Posts: 5,479
    Try putting the locked field on the line level and test on modify line.

    Then set the subpage as editable or not based on the field in the header.
    David Singleton
Sign In or Register to comment.