createCreditMemoDocuments API is used to generate credit memo documents.

APISignature
createCreditMemoDocumentsstatic void createCreditMemoDocuments(List creditMemoIds, String creditMemoTemplateName)

It generates credit memo documents for the given list of credit memo IDs.

You can generate credit memo documents in the following formats:

  • PDF
  • DOCX
  • DOC
  • RTF

It accepts a list of Credit Memo IDs and a valid credit memo template name as input. If you do not specify a valid template name or pass null as a value, Billing Management system uses the default template provided at the Account or the Account Location.

If you call this API from a batch or a scheduled job, it can process only one CreditMemo ID. Otherwise, if you call this API from a non-batch or a non-scheduled job, it can process up to 10 CreditMemos.


Request

Field

Type

Required?

Description

creditMemoIds

List <Id>

Yes IDs of credit memo
creditMemoTemplateNameStringNoName of the credit memo template


Code Sample

Account testAccount = new Account(Name = 'Test Account');
insert testAccount;
CreditMemo__c testCreditMemo = new CreditMemo__c(BillToAccountId__c = testAccount.Id,
 CreditAmount__c = 40.0,
 Status__c = CreditMemo.STATUS_DRAFT);
insert testCreditMemo;
Apttus__APTS_Template__c cmTemplate = new Apttus__APTS_Template__c(Name = 'Default',
 Apttus__IsActive__c = true,
 Apttus__Type__c = 'Credit Memo');
insert cmTemplate;
  
List<Id> cmIdList = new List<Id> {testCreditMemo.Id};
//create Credit Memo Documents
Apttus_Billing.BillingService.createCreditMemoDocuments(cmIdList, cmTemplate.Name);
CODE