pse.UtilizationAnalyticsServiceglobal with sharing class UtilizationAnalyticsService This service provides the functionality relating to Utilization Analytics. Methods
runUtilizationglobal static pse.UtilizationAnalyticsService.RunUtilizationResponse runUtilization() Queues Utilization Analytics Apex jobs to asynchronously process objects required. For example, Timecards and Assignments. Return ValueThe result of the operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. pse.UtilizationAnalyticsService.RunUtilizationResponse response = pse.UtilizationAnalyticsService.runUtilization(); if (!response.errors.isEmpty()){ System.debug('Errors: ' + response.errors); } runUtilizationglobal static pse.UtilizationAnalyticsService.RunUtilizationResponse runUtilization(Date startDate, Date endDate) Queues Utilization Analytics Apex jobs to asynchronously process objects required. For example, Timecards and Assignments. Input Parameters
Return ValueThe result of the operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. pse.UtilizationAnalyticsService.RunUtilizationResponse response = pse.UtilizationAnalyticsService.runUtilization( Date.newInstance(2023, 7, 1), Date.newInstance(2023, 7, 7) ); if (!response.errors.isEmpty()){ System.debug('Errors: ' + response.errors); } runUtilizationglobal static pse.UtilizationAnalyticsService.RunUtilizationResponse runUtilization(pse__Utilization_Setup__c setup) Queues Utilization Analytics Apex jobs to asynchronously process objects required. For example, Timecards and Assignments. Input Parameters
Return ValueThe result of the operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. Utilization_Setup__c setup = new Utilization_Setup__c(); pse.UtilizationAnalyticsService.RunUtilizationResponse response = pse.UtilizationAnalyticsService.runUtilization(setup); if (!response.errors.isEmpty()){ System.debug('Errors: ' + response.errors); } runUtilizationglobal static pse.UtilizationAnalyticsService.RunUtilizationResponse runUtilization(Id setupId) Queues Utilization Analytics Apex jobs to asynchronously process objects required. For example, Timecards and Assignments. Input Parameters
Return ValueThe result of the operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. Id setupId = [SELECT Id FROM pse__Utilization_Setup__c LIMIT 1][0].Id; pse.UtilizationAnalyticsService.RunUtilizationResponse response = pse.UtilizationAnalyticsService.runUtilization(setupId); if (!response.errors.isEmpty()){ System.debug('Errors: ' + response.errors); } runUtilizationForResourceglobal static pse.UtilizationAnalyticsService.RunUtilizationResponse runUtilizationForResource(Id resourceId) Queues Utilization Analytics Apex jobs to asynchronously process for a specific resource. Input Parameters
Return ValueThe result of the operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. Id resourceId = [SELECT Id FROM Contact WHERE pse__Is_Resource__c = True LIMIT 1][0].Id; pse.UtilizationAnalyticsService.RunUtilizationResponse response = pse.UtilizationAnalyticsService.runUtilizationForResource(resourceId); if (!response.errors.isEmpty()){ System.debug('Errors: ' + response.errors); } runUtilizationForResourceglobal static pse.UtilizationAnalyticsService.RunUtilizationResponse runUtilizationForResource(Id resourceId, Date startDate, Date endDate) Queues Utilization Analytics Apex jobs to asynchronously process for a specific resource, between specific dates. Input Parameters
Return ValueThe result of the operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. Id resourceId = [SELECT Id FROM Contact WHERE pse__Is_Resource__c = True LIMIT 1][0].Id; pse.UtilizationAnalyticsService.RunUtilizationResponse response = pse.UtilizationAnalyticsService.runUtilizationForResource( resourceId, Date.newInstance(2023, 7, 1), Date.newInstance(2023, 7, 7) ); if (!response.errors.isEmpty()){ System.debug('Errors: ' + response.errors); } runUtilizationForRoleglobal static pse.UtilizationAnalyticsService.RunUtilizationResponse runUtilizationForRole(String roleName) Queues Utilization Analytics Apex jobs to asynchronously process for a specific role. Input Parameters
Return ValueThe result of the operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. pse.UtilizationAnalyticsService.RunUtilizationResponse response = pse.UtilizationAnalyticsService.runUtilizationForRole('Trainer'); if (!response.errors.isEmpty()){ System.debug('Errors: ' + response.errors); } runUtilizationForRoleglobal static pse.UtilizationAnalyticsService.RunUtilizationResponse runUtilizationForRole(String roleName, Date startDate, Date endDate) Queues Utilization Analytics Apex jobs to asynchronously process for a specific role, between specific dates. Input Parameters
Return ValueThe result of the operation. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. pse.UtilizationAnalyticsService.RunUtilizationResponse response = pse.UtilizationAnalyticsService.runUtilizationForRole( 'Trainer', Date.newInstance(2023, 7, 1), Date.newInstance(2023, 7, 7) ); if (!response.errors.isEmpty()){ System.debug('Errors: ' + response.errors); } isUtilizationAnalyticsTransactionglobal static Boolean isUtilizationAnalyticsTransaction() Checks if the current transaction is running in the Utilization Analytics context. Can be used within a trigger on the Assignment or Resource Request SObject to return early as no additional processing should be carried out when running in the Utilization Analytics context. Return ValueTrue if the current transaction is running in the Utilization Analytics context. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. trigger CustomAssignmentTrigger on pse__Assignment__c (before insert, before update) { if (pse.UtilizationAnalyticsService.isUtilizationAnalyticsTransaction()) { return; } for (Assignment__c assignment : Trigger.new) { assignment.addError('An error occurred'); } } pse.UtilizationAnalyticsService.RunUtilizationResponseglobal inherited sharing class RunUtilizationResponse The response structure from creating a utilization run. Properties
MethodsRunUtilizationResponseglobal RunUtilizationResponse() A constructor that creates a new RunUtilizationResponse instance. |