Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

download

Retrieving Apex Batch Job Information

This global method retrieved the information of the asynchronous apex job running in the backend for a business object.

You can retrieve current information of the following apex jobs:

  • Create and activate Agreement
  • Clone proposal and agreement
  • Finalize proposal and agreement
  • Accept proposal
  • Create and accept Order
  • Asynchronous cart pricing 

API

Signature

getBatchJobInfoForContext

static Apttus_Config2.CPQStruct.JobInfo getBatchJobInfoForContext(Id ctxObjectId)

Request Parameter

Name

Type

Required?

Description

ctxObjectId ID

Yes

The Id of the business object like proposal or agreement.

Response Data Object -Apttus_Config2.CPQStruct.JobInfo

Field

Type

Description

ChildJobs List

The child apex jobs that are associated the original apex jobs.

CompletedDate Datetime

The date and time when the original or child of the apex job was completed.

ExtendedStatus String

The messages of errors encountered during apex job runtime.

JobId Id

The apex job Id

JobName String

The functional and apex job name in the following format:

<Function name>:<apex job name>

JobType String

The type of the apex job. For example, queueable and batchable.

ParentJobId Id

The Id of the given apex job's parent

PercentComplete Integer

The percentage of completion of the apex job at the time when global method was invoked.

Status String

The status of the parent apex job. The following are the possible values:

  • Processing
  • Completed
  • Failed
  • Aborted
SubmittedDate Datetime

The date and time when the apex job was submitted.

Code Sample

The above global method can be used in API polling in a specific interval to retrieve the current status of the apex jobs running in the backend. For example, you are building a custom Lightning Web Component to show the live progress bar with the percentage of completion and status of the job in the proposal object. The Below apex controller calls the global method and returns the percentage of completion and the status to the UI controller to handle.

public static final String STATUS_FAILED = 'Failed'; public static final String STATUS_API_CALLOUT_ERROR = 'APIError'; public static final String GENERIC_JOB_NAME = 'asynchronous'; public static Boolean isLightning = null; public static Boolean isDeployedInPackage = null; public ProposalBannerController(ApexPages.StandardController stdController) { } /** * Gets the async job info for the propoal * @param proposalID id of the quote/proposal record * @return map of status, percentcomplete and jobId to the LWC. */ @AuraEnabled public static Map<String,Object> getBatchJobInfo(String proposalID){ Map<String,Object> responseDO = new Map<String,Object>(); String functionalJobName = GENERIC_JOB_NAME; String asyncClassName = ''; try { Apttus_Config2.CPQStruct.JobInfo parentJobInfo = Apttus_CPQAPI.BatchUpdateService.getBatchJobInfoForContext (proposalID); responseDO.put('parentJobStatus', parentJobInfo.Status); responseDO.put('parentPercentComplete', parentJobInfo.PercentComplete); responseDO.put('parentJobId', parentJobInfo.JobId); if (parentJobInfo.JobName != null) { functionalJobName = parentJobInfo.JobName.split(':')[0]; asyncClassName = parentJobInfo.JobName.split(':')[1] + ':'; } responseDO.put('jobName', functionalJobName); if(parentJobInfo.status == STATUS_FAILED){ responseDO.put('ExtendedStatus', asyncClassName + parentJobInfo.ExtendedStatus); } } catch (Exception e) { // We have to ignore this error in LWC responseDO.put('ExtendedStatus', e.getMessage()); responseDO.put('parentJobStatus', STATUS_API_CALLOUT_ERROR); responseDO.put('jobName', GENERIC_JOB_NAME); } return responseDO; } }