You need to sign in to do that
Don't have an account?
Security.stripInaccessible issue while upserting records, M-D fields ids are being stripped away
Security.stripInaccessible() will remove all ids of non-reparentable M-D fields from the record while using System.AccessType.UPSERTABLE.
That will inevitably result in failures for records which are about to be inserted during the upsert as required m-d realtionship id values were removed.
That makes stripInaccessible fn useless to enfore FLS before commiting to the database if there are any M-D fields involved.
I understand why its happening, but M-D Ids shoud not be removed in this case. And If there are any changed M-D parents for already existing records in dataset, system will prevent it the standard way.
Security.stripInaccessible() is a great and easy replacement for previous implementations, but with this flaw it does not cover all the usecases.
we have encountered the same problem in our developments.
Have you had any more updates from Salesforce, or have you found a work-around for this issue by continuing to use the StripInaccessible method?
Hi Ivano,
No additional details were provided from Salesforce.
You can work around it by using System.AccessType.CREATABLE for upserts but by doing that you will bypass update access check. Might be fine for some scenarios.
Petr.