function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
G2WIntegrationG2WIntegration 

CronTrigger can be inserted by read only user but not deleted - insufficient privileges error

This smells like a bug:

1) Create button that inserts cron triggers

2) Create button that aborts these same cron triggers

3) Have standard or read only (non-admin) user click the button 

4) Have that same user click button to delete crontriggers

 

Expected:

Same permissions apply to #3 & #4

 

Actual:

User can insert, but gets Insufficient Privileges error on abort

 

Is there any way to drop into system mode for these users?  Everything works fine with admins.

 

Insert code sample:

                                    system.schedule('Get Webinars', getWebinarsSchedulerStartTime, new g2wGetWebinarsSchedulerExecute()); 
                                    system.schedule('Get Registrants', getRegistrantsSchedulerStartTime, new g2wGetRegistrantsSchedulerExecute()); 
                                    system.schedule('Get Registrant Details', getRegistrantDetailsSchedulerStartTime, new g2wGetRegistrantDetailsSchedulerExecute()); 
                                    system.schedule('Get Sessions', getSessionsSchedulerStartTime, new g2wGetSessionsSchedulerExecute()); 
                                    system.schedule('Get Webinar Attendees', getAttendeesSchedulerStartTime, new g2wGetWebinarAttendeesSchedulerExecute()); 

 

 

Abort code sample:

List<CronTrigger> cts=[SELECT Id, NextFireTime, State FROM CronTrigger WHERE (CronExpression =: g2wUtils.getWebinarsSchedulerStartTime OR CronExpression =:g2wUtils.getRegistrantsSchedulerStartTime OR CronExpression =:g2wUtils.getSessionsSchedulerStartTime OR CronExpression =: g2wUtils.getRegistrantDetailsSchedulerStartTime OR CronExpression =: g2wUtils.getAttendeesSchedulerStartTime) AND State != 'DELETED'];
        if (cts.size()>0){
            for(CronTrigger ct:cts){
                system.abortJob(ct.Id );
            }//for 1
        }//if 1

 

 

G2WIntegrationG2WIntegration

Update - pretty silly, but "Modify All Data" is required to abort a job, but not needed to insert it.  Seems like a bug.