Promotion Class

This APEX class provides programmatic access to the TPM Promotion SObject and it’s related SObjects.

Namespace

cgcloud

Example Implementation

cgcloud.TPM_Promotion tpmPromotion;

// When saving a promotion, a new MyRecord__c needs to be created
MyRecord__c myRecord = new MyRecord__c(Param1__c='Test');

// Append myRecord to the TPM_Promotion so it's committed when 
// the Promotion is commited to the DB
tpmPromotion.append(myRecord);

TPM_Promotion Methods

The following are methods for TPM_Promotion.

global List<TPM_Promotion.Record> getAttachmentLinks

Returns the List<TPM_Promotion.Record> instances with the Promotion Attachment Links contents.

API Version

55

Signature

global List<TPM_Promotion.Record> getAttachmentLinks()

global TPM_Promotion

This method creates an empty Promotion record.

API Version

55

Signature

global TPM_Promotion()

global List<TPM_Promotion.Record> getAttachments

Returns the List<TPM_Promotion.Record> instances with the Promotion Attachments contents.

API Version

55

Signature

global List<TPM_Promotion.Record> getAttachments()

global List<TPM_Promotion.Record> getProductShares

Returns a filtered List<TPM_Promotion.Record> instances with the Promotion Product Share contents.

API Version

55

Signature

global List<TPM_Promotion.Record> getProductShares(Boolean includeNew, Boolean includeDirty, Boolean includeDeleted )

global List<TPM_Promotion.Record> getAttachments

Returns a filtered List<TPM_Promotion.Record> instances with the Promotion Attachments contents.

API Version

55

Signature

global List<TPM_Promotion.Record> getAttachments(Boolean includeNew, Boolean includeDirty, Boolean includeDeleted )

global List<TPM_Promotion.Record> getAttachmentLinks

Returns a filtered List<TPM_Promotion.Record> instances with the Promotion Attachment Links contents.

API Version

55

Signature

global List<TPM_Promotion.Record> getAttachmentLinks(Boolean includeNew, Boolean includeDirty, Boolean includeDeleted )

global List<TPM_Promotion.Record> getTacticFunds

Returns a filtered List<TPM_Promotion.Record> instances with the Tactic Fund contents.

API Version

55

Signature

global List<TPM_Promotion.Record> getTacticFunds(Boolean includeNew, Boolean includeDirty, Boolean includeDeleted )

global List<TPM_Promotion.Record> getTacticFunds

Returns the List<TPM_Promotion.Record> instances with the Tactic Fund contents.

API Version

55

Signature

global List<TPM_Promotion.Record> getTacticFunds()

global List<TPM_Promotion.TacticRecord> getTactics

Returns the List<TPM_Promotion.Record> instances with the Tactic contents.

API Version

55

Signature

global List<TPM_Promotion.TacticRecord> getTactics()

global List<TPM_Promotion.TacticRecord> getTactics

Returns a filtered List<TPM_Promotion.Record> instances with the Tactic contents..

API Version

55

Signature

global List<TPM_Promotion.TacticRecord> getTactics(Boolean includeNew, Boolean includeDirty, Boolean includeDeleted)

global List<TPM_Promotion.Record> getTacticConditionCreationDefinitions

Returns a filtered List<TPM_Promotion.Record> instances with the Tactic Condition Creation Definitions contents.

API Version

55

Signature

global List<TPM_Promotion.Record> getTacticConditionCreationDefinitions(Boolean includeNew, Boolean includeDirty, Boolean includeDeleted)

global List<TPM_Promotion.Record> getTacticConditionCreationDefinitions

Returns the List<TPM_Promotion.Record> instances with the Tactic Condition Creation Definitions contents.

API Version

55

Signature

global List<TPM_Promotion.Record> getTacticConditionCreationDefinitions()

global List<TPM_Promotion.Record> getProductShares

Returns the List<TPM_Promotion.Record> instances with the Promotion Product Share contents.

API Version

55

Signature

global List<TPM_Promotion.Record> getProductShares()

global Set<Id> getEffectiveCategories

Returns the read only list of effective categories of the promotion.

API Version

55

Signature

global Set<Id> getEffectiveCategories()

global Set<Id> getEffectiveBrands

Returns the read only list of effective brands of the promotion.

API Version

55

Signature

global Set<Id> getEffectiveBrands()

global TPM_ManualInputs getManualInputs

Returns a TPM_ManualInputs instance with the Manual Inputs Information.

API Version

55

Signature

global TPM_ManualInputs getManualInputs()

global TPM_ParticipatingCustomers getParticipatingCustomers

Returns a TPM_ParticipatingCustomers instance with the Participating Customers information.

API Version

55

Signature

global TPM_ParticipatingCustomers getParticipatingCustomers()

global TPM_ProductFilter getProductFilter

Returns the TPM_ProductFilter instance with the Product Filter information

API Version

55

Signature

global TPM_ProductFilter getProductFilter()

global TPM_Promotion

If promotionId is null, throw an exception. This method loads the Promotion record referenced by the input Promotion Id along with its related SObjects.

API Version

55

Signature

global TPM_Promotion(Id promotionId)

global TPM_Promotion.Record append

Appends a Custom SObject Record to the TPM_Promotion instance. This record will be inserted/updated/deleted (depending on the TPM_Promotion.Record instance state) during the same transaction the Promotion object is committed to the database.

API Version

55

Signature

global TPM_Promotion.Record append(SObject record)

Example

cgcloud.TPM_Promotion tpmPromotion;

// When saving a promotion, a new MyRecord__c needs to be created
MyRecord__c myRecord = new MyRecord__c(Param1__c='Test');

// Append myRecord to the TPM_Promotion so it's committed when 
// the Promotion is commited to the DB
tpmPromotion.append(myRecord);

global TPM_Promotion.Record addTacticConditionCreationDefinition

Adds a Tactic Condition Creation Definition Record to the promotion. The returned wrapper can be used for further operations.

API Version

55

Signature

global TPM_Promotion.Record addTacticConditionCreationDefinition(Tactic_Condition_Creation_Definition__c tccd)

global TPM_Promotion.Record addAttachment

Adds a Promotion Attachment Record to the promotion. The returned wrapper can be used for further operations.

API Version

55

Signature

global TPM_Promotion.Record addAttachment(Promotion_Attachment__c pa)

global TPM_Promotion.Record addAttachmentLink

Adds a Promotion Attachment Link Record to the promotion. The returned wrapper can be used for further operations.

API Version

55

Signature

global TPM_Promotion.Record addAttachmentLink(Promotion_Attachment_Link__c pal)

global TPM_Promotion.Record addProductShare

Adds a Promotion Product Share Record to the promotion. The returned wrapper can be used for further operations.

API Version

55

Signature

global TPM_Promotion.Record addProductShare(Promotion_Product_Share__c pps)

global TPM_Promotion.Record addTacticFund

Adds a Tactic Fund Record to the promotion. The returned wrapper can be used for further operations.

API Version

55

Signature

global TPM_Promotion.Record addTacticFund(Tactic_Fund__c tf)

global TPM_Promotion.Record getRecordById

Returns the wrapper object for the record identified by the parameter id. It will search among all the records associated to the promotion.

API Version

55

Signature

global TPM_Promotion.Record getRecordById(Id id)

global TPM_Promotion.TacticRecord addTactic

Adds a Tactic Record to the promotion. The returned wrapper can be used for further operations.

API Version

55

Signature

global TPM_Promotion.TacticRecord addTactic(Tactic__c tactic)

global TPM_Scenarios getScenarios

Returns a TPM_Scenarios instance with the Promotion Scenarios information.

API Version

55

Signature

global TPM_Scenarios getScenarios()

global TPM_SubAccounts getSubAccounts

Returns a TPM_SubAccounts instance with the Sub Accounts information.

API Version

55

Signature

global TPM_SubAccounts getSubAccounts()

global void addRelationship

Notifies the TPM_Promotion instance about a relationship between 2 records. Avoid using direct DML manipulations for Records that are part of the transactional state of a Promotion. During the Promotion Save process, the records provided by the TPM_Promotion instances use temporary Id’s for records that are not still in the database. Using the methods provided by TPM_Promotion object ensures all relationships and Id’s are properly resolved before committing.

API Version

55

Signature

(TPM_Promotion.Record child, SObjectField relationField, TPM_Promotion.Record parent)

Example

cgcloud.TPM_Promotion tpmPromotion;

// When saving a promotion, a new MyRecord__c needs to be created linked to the 
// Promotion__c record by the MyRecord__c.Promotion__c field (lookup or MD field)
MyRecord__c myRecord = new MyRecord__c(Param1__c='Test');

// Append myRecord to the TPM_Promotion so it's committed when 
// the Promotion is commited to the DB
tpmPromotion.append(myRecord);

// Register the relationship to be resolved during the save
tpmPromotion.addRelationship(
    myRecord, // The child record, our new record
    MyRecord__c.Promotion__c, // The field that links both records, its a field on the child object
    tpmPromotion.getPromotion() // The parent record, in this case, the Promotion record
);

global void registerWork

Adds work to be executed after the promotion is committed to the database. Use this method to perform additional operations after all the Promotion related records are correctly committed to the database. See TPM_Promotion.DoWork reference for details about the Interface methods.

API Version

55

Signature

global void registerWork(TPM_Promotion.DoWork work)

global void reload

Removes all the current values and reloads all the promotion data from the Database. This operation is disabled in the TPM_Promotion instance during the Save Promotion Customization Hook.

API Version

55

Signature

global void reload()

global void save

Saves the all the changes contained in promotion SObject record and it’s related SObject records. This operation is disabled in the TPM_Promotion instance during the Save Promotion Customization Hook, as this method will be automatically called when the Core business logic finish processing. The method will need to check the status of the TPM_Promotion.Record wrapper (isDeleted(), isNew()) to determine the DB operation to perform.

API Version

55

Signature

global void save()