0

On an implementation I'm currently working on we have the FFLIB Framework in place. I noted for a requirement to delete specific records that the Framework is enforing triggers to run in context of the User actioning the deletion and not in System mode as per non FFLIB controlled triggers. I found the following Configuration.disableTriggerCRUDSecurity() functionality available however there is some concern in our team on disabling CRUD for this. We would prefer not to provide CRUD specifically in profiles/permission-sets.

A couple of questions have come out of our work on it.

i) Can the User context be switched within the FFLIB framework (https://fflib.dev https://github.com/apex-enterprise-patterns/fflib-apex-common). Can I specifically say I want to change the current running user to a different defined user? I'm presuming not but wanted to check.

ii) When CRUD is disabled via Configuration.disableTriggerCRUDSecurity() Does it just run alone in the current context? I.E. If I disable CRUD in my OpportunityDomain based on a field meeting a certain criteria on a record. I presume it won't therefore be disabled for other record changes which don't meet this criteria. I presume it's literally just the current running context that's affected?

Thanks in advance for any help on this.

1 Answer 1

1

i) Can the User context be switched within the FFLIB framework (https://fflib.dev https://github.com/apex-enterprise-patterns/fflib-apex-common). Can I specifically say I want to change the current running user to a different defined user? I'm presuming not but wanted to check.

Definitely NO. running user is the running user. If you need to use a different running user, you can always publish a Platform Event that is configured to run as a different user. But of course, you then need to accept the logic will be asynchronous

ii) When CRUD is disabled via Configuration.disableTriggerCRUDSecurity() Does it just run alone in the current context? I.E. If I disable CRUD in my OpportunityDomain based on a field meeting a certain criteria on a record. I presume it won't therefore be disabled for other record changes which don't meet this criteria. I presume it's literally just the current running context that's affected?

The disablement is for the specific Domain object being constructed (and hence for the running user)

1
  • Thanks for your help. I presumed This to be the case on both of them but good to get a second opinion on them. Thanks for the suggestion on the Platform Event also. I'll suggest it to our team.
    – RedQueries
    Commented Jun 30, 2023 at 8:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .