Override Form security using x++

We here have a requirement to allow users who are assigned to a security key to be able to modify BOM if the item is in a given status.

So there security for the User group gives them View only on the form, but I want to be able to override that.

here is my code for getting the security key and updating the dataset permissions:

AccessType accessType;
securityKeySet securityKeys;

securityKeys = new SecurityKeySet();
securityKeys.loadUserRights(curuserid());
accessType = securityKeys.access(securitykeynum(‘BomUpdateIndesign’));

if (accessType::Add)
{
bomversion_ds.allowCreate(true);
}

But when I change the Dataset (BomVersion_DS) to allow create or allow edit. The changes do not take effect. So I am not sure how the security is being applied when the form is set to view only?

I see that you put more information to your duplicate thread on another forum, so let’s discuss it there.