SCM Apex API Developer Reference

scmc.InvoicingsService

global with sharing class InvoicingsService

This service is used to support actions that are performed on an invoice.

Methods

isInvoiceToBillingDocumentExportJobScheduled

global static Boolean isInvoiceToBillingDocumentExportJobScheduled()

Checks if the job that exports invoices as billing documents to Foundations is scheduled.

Return Value

Returns true if the job is already scheduled. Otherwise, returns false.

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.

Boolean result = SCMC.InvoicingsService.isInvoiceToBillingDocumentExportJobScheduled();

if(result) {
    // do something in case job scheduled
} else {
    // do something in case job is not scheduled
}

scheduleInvoiceToBillingDocumentExport

global static String scheduleInvoiceToBillingDocumentExport(scmc.InvoicingsService.SchedulerConfiguration schedulerConfig)

Schedules a job to export invoices as billing documents automatically. The method only schedules the job if it is not already scheduled.

Input Parameters

Name Type Description
schedulerConfig scmc.InvoicingsService.SchedulerConfiguration The configuration to schedule job. This includes the cron expression, the number of occurrences, and the start and end dates.

Exceptions Thrown

Value Description
Exception An exception is thrown if a problem occurs when the job is being scheduled.

Return Value

The scheduled job ID.

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.

//This code will schedule the job to run 5 times from today @12:00 AM
SCMC.InvoicingsService.SchedulerConfiguration schedulerConfig = new SCMC.InvoicingsService.SchedulerConfiguration();
schedulerConfig.cronExpression = '0 0 0 * * ?';
schedulerConfig.startDate = System.today();
schedulerConfig.numberOfOccurrences = 5;

String scheduledJobId = SCMC.InvoicingsService.scheduleInvoiceToBillingDocumentExport(schedulerConfig);

invoiceToBillingDocumentExport

global static Set<Id> invoiceToBillingDocumentExport(Set<Id> invoiceIdSet)

Creates a billing document from a given invoice. To create a billing document from an invoice, the invoice must have a status of Closed, an export status of New, display no export errors in the Export Error field, and have a credit status other than Fully Credited. If it has a shipment, the shipment status must be Shipment Complete.

Input Parameters

Name Type Description
invoiceIdSet Set<Id> The IDs of invoices from which billing documents will be created.

Exceptions Thrown

Value Description
Exception An exception is thrown if a problem occurs during the export process.

Return Value

The IDs of the invoices from which billing documents have been successfully created.

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.

Set<Id> invoiceIds = new Set<Id>{'a069E0000004NBO'};

Set<Id> successInvoiceIdSet = SCMC.InvoicingsService.invoiceToBillingDocumentExport(invoiceIds);

scmc.InvoicingsService.SchedulerConfiguration

global inherited sharing class SchedulerConfiguration

Provides the configuration information to create a scheduled job.

Properties

Name Type Description
cronExpression String The cron expression to run the scheduled job.
startDate Date Optional. The date to start running the scheduled job. If no start date is specified, the job starts running as soon as the conditions in the scheduling parameters are met.
endDate Date Optional. The date to stop running the scheduled job. If this property and numberOfOccurrences are not specified, the job won't stop running until it is manually aborted.
numberOfOccurrences Integer Optional. The number of times the scheduled job will be run. If this property and EndDate are not specified, the job won't stop running until it is manually aborted.
© Copyright 2009–2022 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.