SCM Apex API Developer Reference

scmc.PurchaseContractsService

global with sharing class PurchaseContractsService

This class is used to support all the various actions that are performed on a purchase contract.

Enums

DeleteChangeRequestLineAnswerResultType

Enum containing the possible values when a change request line is deleted.

Value Description
Expired The line has been set to a status of “Expired”. This is the value used when the deleted line is associated with an original contract line. In this case, instead of being deleted, the line remains in the change request, but it is set to a status of "Expired".
Deleted The line has been deleted. This is the value used when the deleted line is not associated with an original contract line.

Methods

cancelPurchaseContract

global static void cancelPurchaseContract(Set<Id> purchaseContractIds)

Cancels the specified purchase contracts.

Input Parameters

Name Type Description
purchaseContractIds Set<Id> The IDs of the purchase contracts to be canceled.

Exceptions Thrown

Value Description
DMLException Indicates an issue with a DML statement, such as an "insert" statement missing a required field on a record.

activatePurchaseContract

global static void activatePurchaseContract(Set<Id> purchaseContractIds)

Activates the specified purchase contracts and their purchase contract lines.

Input Parameters

Name Type Description
purchaseContractIds Set<Id> The IDs of the purchase contracts to be activated.

Exceptions Thrown

Value Description
DMLException Indicates an issue with a DML statement, such as an "insert" statement missing a required field on a record.

applyChangeRequest

global static scmc.PurchaseContractsService.ApplyChangeRequestAnswer applyChangeRequest(Id changeRequestId)

Applies the specified change request to its purchase contract. Only approved change requests can be applied.

Input Parameters

Name Type Description
changeRequestId Id The ID of the change request to be applied.

Return Value

This method returns an ApplyChangeRequestAnswer object.

createChangeRequests

global static Map<Id, scmc.PurchaseContractsService.CreateChangeRequestsAnswer> createChangeRequests(Set<Id> purchaseContractIds)

Creates change requests for the specified purchase contracts. Change request can only be created for active contracts.

Input Parameters

Name Type Description
purchaseContractIds Set<Id> The IDs of the purchase contracts that change requests will be created for.

Return Value

This method returns a map of purchase contract IDs and CreateChangeRequestsAnswer objects.

deleteChangeRequestLine

global static Map<Id, scmc.PurchaseContractsService.DeleteChangeRequestLineAnswer> deleteChangeRequestLine(Set<Id> changeRequestLinesIds)

Deletes the specified change request lines. Lines associated with an original contract line are set to a status of Expired.

Input Parameters

Name Type Description
changeRequestLinesIds Set<Id> The IDs of the change request lines to be deleted.

Return Value

This method returns a map of line IDs and deleteChangeRequestLineAnswer objects.

deepClone

global static Id deepClone(Id purchaseContractId)

Creates a copy of the specified purchase contract including all lines.
All fields are cloned, including custom fields.
The new purchase contract does not have a relationship with other purchase contracts or requisitions.

The following fields are reset:

  • Purchase contract's header
    • SCMC__Status__c = Draft
    • SCMC__Amount_On_Order__c = 0
    • SCMC__Quantity_On_Order__c = 0
    • SCMC__Amount_Matched__c = 0
    • SCMC__Quantity_Matched__c = 0
    • SCMC__Amount_Received__c = 0
    • SCMC__Quantity_Received__c = 0
    • SCMC__Original_Purchase_Contract__c = null
    • SCMC__Previous_Contract__c = null

  • Purchase contract's lines
    • SCMC__Status__c = Draft
    • SCMC__Amount_On_Order__c = 0
    • SCMC__Quantity_On_Order__c = 0
    • SCMC__Amount_Matched__c = 0
    • SCMC__Quantity_Matched__c = 0
    • SCMC__Amount_Received__c = 0
    • SCMC__Quantity_Received__c = 0
    • SCMC__Original_Contract_Line__c = null
    • SCMC__Previous_Contract_Line__c = null
    • SCMC__Requisition_Line__c = null

Input Parameters

Name Type Description
purchaseContractId Id The ID of the purchase contract to be cloned.

Return Value

The ID of the cloned purchase contract.

renew

global static Id renew(Id purchaseContractId)

Renews an existing purchase contract in a status of Active or Expired, as well as all of its lines, provided that they are in any status other than Canceled, and that the End Date field has a value.

The renewed purchase contract is created with the same field values as the original purchase contract, with the following exceptions:

  • Purchase Contract header
    • SCMC__Status__c = Draft
    • SCMC__Start_Date__c = Day after of the End Date field from the original purchase contract.
    • SCMC__End_Date__c = New Start Date + days between Start Date and End Date fields from the original purchase contract.
    • SCMC__Amount_On_Order__c = 0
    • SCMC__Amount_Received__c = 0
    • SCMC__Amount_Matched__c = 0
    • SCMC__Quantity_On_Order__c = 0
    • SCMC__Quantity_Received__c = 0
    • SCMC__Quantity_Matched__c = 0
    • SCMC__Original_Purchase_Contract__c = The ID from which the renewed purchase contract is created.
    • SCMC__Previous_Contract__c = null
    • SCMC_Renewal_Reminder_c = If it is not empty, it will be: The End Date field from the renewed purchase contract minus the days between the original purchase contract's End Date field and the Renewal Reminder's date

  • Purchase Contract lines
    • SCMC__Status__c = Draft
    • SCMC__Start_Date__c = If the Start Date field on the original purchase contract line is empty, it will be empty. If not, it will be: Start Date field from the renewed purchase contract's header + days between the Start Date field on the original purchase contract's header and the Start Date field from the original purchase contract line.
    • SCMC__End_Date__c = If the End Date field on the original purchase contract line is empty, it will be empty. If not, it will be: New Start Date field for the purchase contract line + days between Start Date and End date fields from the original purchase contract line.
    • SCMC__Amount_On_Order__c = 0
    • SCMC__Amount_Received__c = 0
    • SCMC__Amount_Matched__c = 0
    • SCMC__Quantity_On_Order__c = 0
    • SCMC__Quantity_Received__c = 0
    • SCMC__Quantity_Matched__c = 0
    • SCMC__Original_Contract_Line__c = The ID from which the renewed purchase contract line is created.
    • SCMC__Previous_Contract_Line__c = null
    • SCMC__Requisition_Line__c = null

Input Parameters

Name Type Description
purchaseContractId Id The ID of the purchase contract to be renewed.

Return Value

The ID of the renewed purchase contract.

renew

global static Id renew(Id purchaseContractId, Date newStartDate, Date newEndDate)

Renews an existing purchase contract in a status of Active or Expired, as well as all of its lines, provided that they are in any status other than Canceled, and that the End Date field has a value.

The renewed purchase contract is created with the same field values as the original purchase contract, with the following exceptions:

  • Purchase contract's header
    • SCMC_Status_c = Draft
    • SCMC_Start_Date_c = The assigned value comes from the parameter newStartDate if the field is not empty, otherwise it will be: The End Date field from the renewed purchase contract's header + one day.
    • SCMC_End_Date_c = The assigned value comes from the parameter newEndDate if the field is not empty, otherwise it will be: The calculated new Start Date field + the days between Start Date and End date fields from the original purchase contract line.
    • SCMC_Amount_On_Order_c = 0
    • SCMC_Amount_Received_c = 0
    • SCMC_Amount_Matched_c = 0
    • SCMC_Quantity_On_Order_c = 0
    • SCMC_Quantity_Received_c = 0
    • SCMC_Quantity_Matched_c = 0
    • SCMC_Original_Purchase_Contract_c = The ID from which the renewed purchase contract is created.
    • SCMC_Previous_Contract_c = null
    • SCMC_Renewal_Reminder_c = If it is not empty, it will be: The End Date field from the renewed purchase contract minus the days between the original purchase contract's End Date field and the Renewal Reminder's date

  • Purchase contract's lines
    • SCMC_Status_c = Draft
    • SCMC_Start_Date_c = If the Start Date field on the original purchase contract line is empty, it will be empty. If not, it will be: The new Start Date field from the renewed purchase contract's header + the days between the Start Date field on the original purchase contract's header and the Start Date field from the original purchase contract line.
    • SCMC_End_Date_c = If the End Date field on the original purchase contract line is empty, it will be empty. If not, it will be: The new Start Date field for the purchase contract line + the days between the Start Date and End date fields from the original purchase contract line.
    • SCMC_Amount_On_Order_c = 0
    • SCMC_Amount_Received_c = 0
    • SCMC_Amount_Matched_c = 0
    • SCMC_Quantity_On_Order_c = 0
    • SCMC_Quantity_Received_c = 0
    • SCMC_Quantity_Matched_c = 0
    • SCMC_Original_Contract_Line_c = The ID from which the renewed purchase contract line is created.
    • SCMC_Previous_Contract_Line_c = null
    • SCMC_Requisition_Line_c = null

Input Parameters

Name Type Description
purchaseContractId Id The ID of the purchase contract to be renewed.
newStartDate Date The start date to be assigned to the renewed purchase contract.
newEndDate Date Then end date to be assigned to the renewed purchase contract.

Return Value

The ID of the renewed purchase contract.

scmc.PurchaseContractsService.ApplyChangeRequestAnswer

global inherited sharing class ApplyChangeRequestAnswer

This class is used as the object returned by the applyChangeRequest global service. This object contains a change request ID and the ID of the purchase contract it is applied to. If a change request ID is invalid and cannot be applied, an error message is returned instead of the purchase contract ID.

Properties

Name Type Description
ChangeRequestId Id The ID of the applied change request.
OriginalContractId Id The ID of the purchase contract that the change request is applied to.
ErrorMessage String The error message returned if a problem occurs when the change request is being applied.

Methods

ApplyChangeRequestAnswer

global ApplyChangeRequestAnswer()

scmc.PurchaseContractsService.CreateChangeRequestsAnswer

global inherited sharing class CreateChangeRequestsAnswer

This class is used as the object returned by the createChangeRequests global service. One object containing the ID of the created change request is returned for each generated record. If a change request is not created due to one or more errors, a list of error messages is returned.

Properties

Name Type Description
ChangeRequestId Id The ID of the created change request.
ErrorMessagesList List<String> The list of error messages received if a problem occurs during the creation process.

Methods

CreateChangeRequestsAnswer

global CreateChangeRequestsAnswer()

scmc.PurchaseContractsService.DeleteChangeRequestLineAnswer

global inherited sharing class DeleteChangeRequestLineAnswer

This class is used as the object returned by the deleteChangeRequestLine global service. This object contains the ID of the change request that the deleted line belongs to and the result of the line deletion process. If a line cannot be deleted because its ID is invalid, an error message is returned instead of the line status.

Properties

Name Type Description
PurchaseContractId Id The ID of the change request that the deleted line belongs to.
Result scmc.PurchaseContractsService.DeleteChangeRequestLineAnswerResultType The result of the line deletion process. A value of "Deleted" indicates the line has been deleted. A value of "Expired" indicates the line has been expired.
Errors List<String> The list of error messages received if a problem occurs during the line deletion process.

Methods

DeleteChangeRequestLineAnswer

global DeleteChangeRequestLineAnswer()

© Copyright 2009–2022 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.