Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
ScheduleJobsApi Class
Namespace
Usage
This API uses two methods, getJob and setTerritory. getJob passes a job to setTerritory, and setTerritory applies a territoryID and groupPolicyID to that job via GroupData.
ScheduleJobsApi Methods
ScheduleJobsApi includes the following static methods.
getJob
Signature
Parameters
- jobName
- Type: String
- Required. The name of the job to update for service territory. The job name is case-sensitive.
Return Value
Type: ScheduleJobsApi(validateJobId(jobId))
Usage
This method passes a job to setTerritory, which updates the Territory tab. See setTerritory for sample code.
setTerritory
Signature
Parameters
- groupList
- Type: List<GroupData>
- Required. A list of GroupData objects representing the territories and group policies to be associated with the job.
Return Value
Type: Void
Usage
This method configures the Territory tab based on optimized territory and scheduling policy for a scheduled job. Here are two examples of code that configures the territory tab for a scheduled job.
Example 1:
1String jobName = 'Optimization';
2
3List<FSL.ScheduleJobsApi.GroupData> groupList = new List<FSL.ScheduleJobsApi.GroupData>();
4
5FSL.ScheduleJobsApi.GroupData firstGroup = new FSL.ScheduleJobsApi.GroupData
6 ('a0cSM0000000fEU', new List<String>{'0HhSM0000000S5x', '0HhSM0000000TbV0AU'});
7
8FSL.ScheduleJobsApi.GroupData secondGroup = new FSL.ScheduleJobsApi.GroupData
9 ('0', new List<String>{'0HhSM0000000RbJ'});
10
11groupList.add(firstGroup);
12groupList.add(secondGroup);
13
14FSL.ScheduleJobsApi.GetJob(jobName).setTerritory(groupList);Example 2:
1String jobName = "Optimization";
2
3// Get all service territory groups.
4List<YourGroupType> All_ST_GROUPS = getAllGroupsFromAnotherSource();
5
6List<FSL.ScheduleJobsApi.GroupData> groupList = new List<FSL.ScheduleJobsApi.GroupData>();
7
8for (Integer i = 0; i < All_ST_GROUPS.size(); i++) {
9 FSL.ScheduleJobsApi.GroupData groupData = new FSL.ScheduleJobsApi.GroupData(
10 All_ST_GROUPS[i].policyId,
11 new List<String> {
12 All_ST_GROUPS[i].territoryIds
13 }
14 );
15 // Add the created groupData to the list.
16 groupList.add(groupData);
17}
18
19FSL.ScheduleJobsApi.GetJob(jobName).setTerritory(groupList);