Scope: managed applications, ordinary applications.
2. If it is not required to add or delete scheduled jobs depending on user actions or configuration logic, use predefined scheduled jobs. These jobs are automatically created in the infobase with the schedule and state specified by the developer in Designer. Examples of predefined scheduled jobs:
- Import exchange rates
- Extract text for full-text indexing
- Update aggregates
3.1. If execution of a scheduled job depends on one or more enabled functional options, programmatically manage the Use flag of the predefined scheduled job depending on the enabled functional options. Otherwise, scheduled jobs lead to start of sessions and decrease computing performance of 1C:Enterprise server.
For example, there is the SendReceiveEmails scheduled job with Use check box selected. It must be executed only if the UseEmailClient functional option is enabled.
Incorrect: create a predefined scheduled job that depends on a functional option with the Use check box selected.
Correct: clear the Use check box and manage a scheduled job depending on enabling or disabling the functional option.
If the "Scheduled jobs" subsystem of Standard Subsystems Library is available in the configuration, use the OnDefineScheduledJobsSettings procedure of the ScheduledJobsOverridable common module. For example:
Setting = Settings.Add();
Setting.ScheduledJob = Metadata.ScheduledJobs.SMSDeliveryStatusUpdate;
Setting.FunctionalOption = Metadata.FunctionalOptions.UseEmailClient;
Setting.AvailableSaaS = False;
After that, add constants, which correspond to functional options used to manage scheduled jobs, to the FunctionalOptionsStorage user-defined type.
For configurations without SSL, manage scheduled jobs, for example, by placing the following code in the UseEmailClient constant values of the manager module:
If Job.Use <> Value Then
Job.Use = Value;
3.2. To provide secure execution of scheduled jobs started from the console or otherwise without enabling functional options, add the following code to the beginning of the procedure of the scheduled job data processor:
If NOT GetFunctionalOption("UseEmailClient") Then
Raise NStr("en = "The scheduled job is unavailable by functional options.'");
If SSL "Scheduled jobs" subsystem is available in the configuration and dependences of scheduled jobs on functional options are set (see cl. 3.1), it is sufficient to insert a call as described in cl. 6.
- Data exchange with other infobases must be carried out with each infobase on schedule.
- Each extra data processor must be started in the infobase on individual schedule.
In these cases, create instances of scheduled jobs and parameterize them using infobase objects (for example, infobase nodes, the Additional data processors catalog items, and other) from 1C:Enteprise code using the Scheduled jobs.CreateScheduledJob method. In the Description property, specify a presentation of the object used to create the scheduled job. For example, you have a report mailing (a catalog item), a schedule set up in the mailing card and the user who created it. In this case, adding a scheduled job on its basis is as follows:
// Removing restriction of creating scheduled jobs by administrator only.
Job = ScheduledJobs.CreateScheduledJob(Metadata.ScheduledJobs.ReportDistribution);
JobParameters = New Array;
Job.Parameters = JobParameters;
Job.Username = MailedBy;
Job.Use = True;
Job.Description = StringFunctionsClientServer.SubstituteParametersToString(Nstr("en = "Report distribution: %1'"), TrimAll(ReportDistribution);
Job.Schedule = DistributionSchedule;
4.2. If SSL "Scheduled jobs" subsystem is used in the configuration, restrict interactive creation and start of parameterized scheduled jobs from the Scheduled and background jobs form. To set the restriction, specify the job in the OnDefineScheduledJobsSettings procedure of the ScheduledJobsOverridable common module. For example:
Setting = Settings.Add();
Setting.ScheduledJob = Metadata.ScheduledJobs.ReportDistribution;
Setting.IsParameterized = True;
See also cl. 6.
5. To avoid conflicts, we recommend that you automatically lock all scheduled jobs, which access external resources (mailings, data synchronization with other applications, and other) in infobase copies. For example, if an infobase copy is deployed for testing or delivered to technical support.
If SSL "Scheduled jobs" subsystem is available in the configuration, list the following jobs in the OnDefineScheduledJobsSettings procedure of the ScheduledJobsOverridable common module. For example:
See also cl. 6.
In this case, when transferring an infobase, the administrator will be prompted to disable such jobs.
The first parameter is required.