0

Custom apex trigger initiates a change on opportunity(from within a without sharing static class). Which than apply DML update operation. Validation rule fails on opportunity. The validation rule check weather the change was from a certain profile.id(system administrator)

Without sharing class runs within a system execution context, Is it suppose to fail? Is it possible to run it as a specific user?

2 Answers 2

1

Without sharing class runs within a system execution context, Is it suppose to fail?

Even though the code runs in system mode, the running user's profile doesn't change. So yes, the validation rule should apply.

Is it possible to run it as a specific user?

No, otherwise it would cause a data integrity issue. Only possible option is to run without or without sharing as you know.

2

Yes, the user and profile is the same with or without sharing. Without sharing only by-passes permissions, but it does NOT run-as Admin, hence... the validation rule fails

You must log in to answer this question.

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