Sie befinden sich hier:
Aktualisieren Ihrer Schichtarbeitsthemen für die kapazitätsbasierte Planung
Bereiten Sie Ihre Organisation auf die kapazitätsbasierte Planung vor, indem Sie die Schichtarbeitsthemen aktualisieren.
Erforderliche Editionen
| Verfügbarkeit: Lightning Experience. |
| Verfügbarkeit: Enterprise und Unlimited Edition |
| Erforderliche Benutzerberechtigungen | |
|---|---|
| Ausführen des Skripts: | API aktiviert UND Alle Daten anzeigen UND Autor-Apex |
Überprüfen Sie Ihre Organisation auf Schichtarbeitsthemen, bei denen das Kontrollkästchen Alle unterstützten Themen mit diesen Skripts aktiviert ist. Für solche Schichtarbeitsthemen löscht das Skript sie und erstellt dann einzelne Schichtarbeitsthemen für alle Arbeitstypen oder Arbeitstypgruppen.
-
Kopieren Sie je nach Einstellung "Planer für Health Cloud" in Ihrer Organisation eines der folgenden Skripts.
- Deaktiviert
global class BatchProcessShiftWorkTerritory implements Database.Batchable<SObject> { global Database.QueryLocator start(Database.BatchableContext BC) { return Database.getQueryLocator( [SELECT Id FROM Shift ] ); } global void execute(Database.BatchableContext BC, List<SObject> scope) { List<String> shiftIds = new List<String>(); for (Shift shift : (List<Shift>) scope) { shiftIds.add(shift.Id); } List<ShiftWorkTopic> shiftWorkTopicsWithAllTopicsSupported = [ SELECT Id, ShiftId, WorkTypeGroupId FROM ShiftWorkTopic WHERE AreAllTopicsSupported = TRUE AND ShiftId IN :shiftIds ]; List<ShiftWorkTopic> shiftWorkTopicsWithAllTopicsNotSupported = [ SELECT WorkTypeGroupId, ShiftId FROM ShiftWorkTopic WHERE AreAllTopicsSupported = FALSE AND ShiftId IN :shiftIds ]; List<ShiftWorkTopic> newShiftWorkTopics = new List<ShiftWorkTopic>(); List<WorkTypeGroup> allWorkTypeGroups = [ SELECT Id FROM WorkTypeGroup ]; Set<Set<String>> allCombinationsOfWorkTypeGroupAndShift = new Set<Set<String>>(); for (ShiftWorkTopic swt : shiftWorkTopicsWithAllTopicsNotSupported) { allCombinationsOfWorkTypeGroupAndShift.add( new Set<String>{ swt.WorkTypeGroupId, swt.ShiftId } ); } // Loop through enabled ShiftWorkTopics and all WorkTypeGroups for ( ShiftWorkTopic enabledTopic : shiftWorkTopicsWithAllTopicsSupported ) { for (WorkTypeGroup workTypeGroup : allWorkTypeGroups) { if ( !allCombinationsOfWorkTypeGroupAndShift.contains( new Set<String>{ workTypeGroup.Id, enabledTopic.ShiftId } ) ) { newShiftWorkTopics.add( new ShiftWorkTopic( WorkTypeGroupId = workTypeGroup.Id, ShiftId = enabledTopic.ShiftId ) ); } } } // Insert the new ShiftWorkTopic records insert newShiftWorkTopics; // Delete the enabled ShiftWorkTopics delete shiftWorkTopicsWithAllTopicsSupported; } global void finish(Database.BatchableContext BC) { // Send notification or log the completion System.debug('Batch job completed successfully.'); } } - Aktiviert
global class BatchProcessShiftWorkTerritory implements Database.Batchable<SObject> { global Database.QueryLocator start(Database.BatchableContext BC) { return Database.getQueryLocator( [SELECT Id FROM Shift ] ); } global void execute(Database.BatchableContext BC, List<SObject> scope) { List<String> shiftIds = new List<String>(); for (Shift shift : (List<Shift>) scope) { shiftIds.add(shift.Id); } List<ShiftWorkTopic> shiftWorkTopicsWithAllTopicsSupported = [ SELECT Id, ShiftId, WorkTypeId FROM ShiftWorkTopic WHERE AreAllTopicsSupported = TRUE AND ShiftId IN :shiftIds ]; List<ShiftWorkTopic> shiftWorkTopicsWithAllTopicsNotSupported = [ SELECT WorkTypeId, ShiftId FROM ShiftWorkTopic WHERE AreAllTopicsSupported = FALSE AND ShiftId IN :shiftIds ]; List<ShiftWorkTopic> newShiftWorkTopics = new List<ShiftWorkTopic>(); List<WorkType> allWorkTypes = [ SELECT Id FROM WorkType ]; Set<Set<String>> allCombinationsOfWorkTypeAndShift = new Set<Set<String>>(); for (ShiftWorkTopic swt : shiftWorkTopicsWithAllTopicsNotSupported) { allCombinationsOfWorkTypeAndShift.add( new Set<String>{ swt.WorkTypeId, swt.ShiftId } ); } // Loop through enabled ShiftWorkTopics and all WorkTypes for ( ShiftWorkTopic enabledTopic : shiftWorkTopicsWithAllTopicsSupported ) { for (WorkType workType : allWorkTypes) { if ( !allCombinationsOfWorkTypeAndShift.contains( new Set<String>{ workType.Id, enabledTopic.ShiftId } ) ) { newShiftWorkTopics.add( new ShiftWorkTopic( WorkTypeId = workType.Id, ShiftId = enabledTopic.ShiftId ) ); } } } insert newShiftWorkTopics; delete shiftWorkTopicsWithAllTopicsSupported; } global void finish(Database.BatchableContext BC) { // Send notification or log the completion System.debug('Batch job completed successfully.'); } }
- Deaktiviert
- Erstellen Sie eine Apex-Klasse mit dem Namen BatchProcessShiftWorkTerritory, um Genehmigungs-Workflows auszulösen. Siehe Definieren von Apex-Klassen.
- Wählen Sie Developer Console unter "Setup" aus.
- Klicken Sie in der Developer Console auf Debug und dann auf Open Execute Anonymous Window (Anonymes Fenster öffnen).
-
Führen Sie diesen Code aus.
BatchProcessShiftWorkTerritory batchJob = new BatchProcessShiftWorkTerritory(); Integer batchSize = 100; Database.executeBatch(batchJob, batchSize); - Wenn Sie den Fortschritt des Skripts anzeigen möchten, suchen Sie unter "Setup" nach Apex Aufträge und wählen Sie diese Option aus.
Konnten Sie Ihr Problem mithilfe dieses Artikels lösen?
Geben Sie uns Feedback, damit wir uns verbessern können.

