Validation rule Scheduled ApexValidation RuleValidation rule syntaxValidation RuleValidation Rule - Cannot filter by record typeGetting error while updating record through After update triggerLPAD or RPAD Validation RuleConfigurable validation ruleValidation rule to prevent a profile user to edit a record in certain caseError message not displaying in validation rule

Conveying the idea of "It's piece of cake" by "simple comme bonjour" or "bête comme chou"

Dynamics m, r, s, and z. What do they mean?

Rule of thumb: how far before changing my chain to prevent cassette wear

How did Ron get five hundred Chocolate Frog cards?

Skewer removal without quick release

Is Schrodinger's Cat itself an observer?

Using Terminal` (ASCII plots) in Wolfram 12

Do I need to explicitly handle negative numbers or zero when summing squared digits?

What is the name for a fluid transition between two tones? When did it first appear?

Paper status "Accept with Shepherd". What does it really mean?

How to print and use a command output in a one-liner?

Can you take an Immortal Phoenix out of the game?

What are the physical limits that determine a camera's flash sync speed?

Can I get bubble tea at Taiyuan airport?

SSD or HDD for server

Is there a historical explanation as to why the USA people are so litigious compared to France?

Is there a push, in the United States, to use gender-neutral language and gender pronouns (when they are given)?

Variable fixing based on a good feasible solution

"Table" method for expanding brackets vs "each term in the first bracket gets multiplied by each term in the second bracket"

How to get the SMILES of all compounds on PubChem?

Why are KDFs slow? Is using a KDF more secure than using the original secret?

Ginger Baker dead: Why is he been called the most dangerous drummer?

Why "come" instead of "go"?

What is it called when you use wrong but smart arguments?



Validation rule Scheduled Apex


Validation RuleValidation rule syntaxValidation RuleValidation Rule - Cannot filter by record typeGetting error while updating record through After update triggerLPAD or RPAD Validation RuleConfigurable validation ruleValidation rule to prevent a profile user to edit a record in certain caseError message not displaying in validation rule






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









2

















I have a scheduled apex job which updates a field which is controlled by a validation rule as follows:



AND(
Not(ISNEW()),
$Profile.Name != "System Administrator",
ISCHANGED(theFieldInQuestion)
)


This validation rule prevents anyone from changing the value in theFieldInQuestion UNLESS that person is a System Administrator.



The scheduler runs as system, according to the documentation located here:




https://help.salesforce.com/articleView?id=code_schedule_batch_apex.htm&type=0




My question is : What can I add to this AND clause in the validation rule which would allow the Scheduled Apex Job to update theFieldInQuestion ?










share|improve this question




























  • In the Scheduled Jobs list, what is the profile of the User shown as having Submitted the job?

    – Thomas Taylor
    May 2 at 12:55

















2

















I have a scheduled apex job which updates a field which is controlled by a validation rule as follows:



AND(
Not(ISNEW()),
$Profile.Name != "System Administrator",
ISCHANGED(theFieldInQuestion)
)


This validation rule prevents anyone from changing the value in theFieldInQuestion UNLESS that person is a System Administrator.



The scheduler runs as system, according to the documentation located here:




https://help.salesforce.com/articleView?id=code_schedule_batch_apex.htm&type=0




My question is : What can I add to this AND clause in the validation rule which would allow the Scheduled Apex Job to update theFieldInQuestion ?










share|improve this question




























  • In the Scheduled Jobs list, what is the profile of the User shown as having Submitted the job?

    – Thomas Taylor
    May 2 at 12:55













2












2








2








I have a scheduled apex job which updates a field which is controlled by a validation rule as follows:



AND(
Not(ISNEW()),
$Profile.Name != "System Administrator",
ISCHANGED(theFieldInQuestion)
)


This validation rule prevents anyone from changing the value in theFieldInQuestion UNLESS that person is a System Administrator.



The scheduler runs as system, according to the documentation located here:




https://help.salesforce.com/articleView?id=code_schedule_batch_apex.htm&type=0




My question is : What can I add to this AND clause in the validation rule which would allow the Scheduled Apex Job to update theFieldInQuestion ?










share|improve this question
















I have a scheduled apex job which updates a field which is controlled by a validation rule as follows:



AND(
Not(ISNEW()),
$Profile.Name != "System Administrator",
ISCHANGED(theFieldInQuestion)
)


This validation rule prevents anyone from changing the value in theFieldInQuestion UNLESS that person is a System Administrator.



The scheduler runs as system, according to the documentation located here:




https://help.salesforce.com/articleView?id=code_schedule_batch_apex.htm&type=0




My question is : What can I add to this AND clause in the validation rule which would allow the Scheduled Apex Job to update theFieldInQuestion ?







formula scheduled-apex validation-rule






share|improve this question















share|improve this question













share|improve this question




share|improve this question



share|improve this question








edited May 2 at 12:54









Thomas Taylor

4,12615 silver badges35 bronze badges




4,12615 silver badges35 bronze badges










asked May 2 at 12:45









george ostergeorge oster

586 bronze badges




586 bronze badges















  • In the Scheduled Jobs list, what is the profile of the User shown as having Submitted the job?

    – Thomas Taylor
    May 2 at 12:55

















  • In the Scheduled Jobs list, what is the profile of the User shown as having Submitted the job?

    – Thomas Taylor
    May 2 at 12:55
















In the Scheduled Jobs list, what is the profile of the User shown as having Submitted the job?

– Thomas Taylor
May 2 at 12:55





In the Scheduled Jobs list, what is the profile of the User shown as having Submitted the job?

– Thomas Taylor
May 2 at 12:55










1 Answer
1






active

oldest

votes


















8


















Scheduled Apex runs in system mode, but that's not the same as running with a context user that is a system administrator. In system mode, FLS and CRUD aren't enforced against you (you control the enforcement of Record-Level security via [with|without|inherited] sharing declarations), and Apex class permissions are ignored.



Every Scheduled Apex job has a context user, which is the user who scheduled the job. Each time the job is executed, it remains in the context of that user and their profile and role. If the Scheduled Apex job is scheduled by, for example, a Standard User, it will run in system mode, but under the rubric of that user. UserInfo.getUserId() will return their Id, and any and all formula-type references to User fields will refer to them.



Easy fixes:



  • Schedule the class by doing Login As the desired System Administrator

  • Change the validation rule to vet changes by looking at a Custom Permission with $Permission.some_permission_name, and assign that Custom Permission to allowed users via a Permission Set.





share|improve this answer



























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "459"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f260877%2fvalidation-rule-scheduled-apex%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown


























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    8


















    Scheduled Apex runs in system mode, but that's not the same as running with a context user that is a system administrator. In system mode, FLS and CRUD aren't enforced against you (you control the enforcement of Record-Level security via [with|without|inherited] sharing declarations), and Apex class permissions are ignored.



    Every Scheduled Apex job has a context user, which is the user who scheduled the job. Each time the job is executed, it remains in the context of that user and their profile and role. If the Scheduled Apex job is scheduled by, for example, a Standard User, it will run in system mode, but under the rubric of that user. UserInfo.getUserId() will return their Id, and any and all formula-type references to User fields will refer to them.



    Easy fixes:



    • Schedule the class by doing Login As the desired System Administrator

    • Change the validation rule to vet changes by looking at a Custom Permission with $Permission.some_permission_name, and assign that Custom Permission to allowed users via a Permission Set.





    share|improve this answer






























      8


















      Scheduled Apex runs in system mode, but that's not the same as running with a context user that is a system administrator. In system mode, FLS and CRUD aren't enforced against you (you control the enforcement of Record-Level security via [with|without|inherited] sharing declarations), and Apex class permissions are ignored.



      Every Scheduled Apex job has a context user, which is the user who scheduled the job. Each time the job is executed, it remains in the context of that user and their profile and role. If the Scheduled Apex job is scheduled by, for example, a Standard User, it will run in system mode, but under the rubric of that user. UserInfo.getUserId() will return their Id, and any and all formula-type references to User fields will refer to them.



      Easy fixes:



      • Schedule the class by doing Login As the desired System Administrator

      • Change the validation rule to vet changes by looking at a Custom Permission with $Permission.some_permission_name, and assign that Custom Permission to allowed users via a Permission Set.





      share|improve this answer




























        8














        8










        8









        Scheduled Apex runs in system mode, but that's not the same as running with a context user that is a system administrator. In system mode, FLS and CRUD aren't enforced against you (you control the enforcement of Record-Level security via [with|without|inherited] sharing declarations), and Apex class permissions are ignored.



        Every Scheduled Apex job has a context user, which is the user who scheduled the job. Each time the job is executed, it remains in the context of that user and their profile and role. If the Scheduled Apex job is scheduled by, for example, a Standard User, it will run in system mode, but under the rubric of that user. UserInfo.getUserId() will return their Id, and any and all formula-type references to User fields will refer to them.



        Easy fixes:



        • Schedule the class by doing Login As the desired System Administrator

        • Change the validation rule to vet changes by looking at a Custom Permission with $Permission.some_permission_name, and assign that Custom Permission to allowed users via a Permission Set.





        share|improve this answer














        Scheduled Apex runs in system mode, but that's not the same as running with a context user that is a system administrator. In system mode, FLS and CRUD aren't enforced against you (you control the enforcement of Record-Level security via [with|without|inherited] sharing declarations), and Apex class permissions are ignored.



        Every Scheduled Apex job has a context user, which is the user who scheduled the job. Each time the job is executed, it remains in the context of that user and their profile and role. If the Scheduled Apex job is scheduled by, for example, a Standard User, it will run in system mode, but under the rubric of that user. UserInfo.getUserId() will return their Id, and any and all formula-type references to User fields will refer to them.



        Easy fixes:



        • Schedule the class by doing Login As the desired System Administrator

        • Change the validation rule to vet changes by looking at a Custom Permission with $Permission.some_permission_name, and assign that Custom Permission to allowed users via a Permission Set.






        share|improve this answer













        share|improve this answer




        share|improve this answer



        share|improve this answer










        answered May 2 at 12:55









        David ReedDavid Reed

        51.7k8 gold badges29 silver badges68 bronze badges




        51.7k8 gold badges29 silver badges68 bronze badges































            draft saved

            draft discarded















































            Thanks for contributing an answer to Salesforce Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f260877%2fvalidation-rule-scheduled-apex%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown









            Popular posts from this blog

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?