Newer Version Available
TPM_Promotion.Record
This APEX class provides a wrapper to Promotion SObject Records. Each instance wraps an
SObject Record related to the parent TPM_Promotion and provide methods to manipulate them in order
to flag them for insertion or deletion. It also provides methods to extract the underlying SObject
records so updates can be made.
Namespace
1cgcloudExample Implementation
1cgcloud.TPM_Promotion tpmPromotion;
2
3// Append the object to create a wrapper
4cgcloud.TPM_Promotion.Record myRecord = tpmPromotion.append(new MyRecord__c());
5
6// Set field values using a Map
7myRecord.setField(new Map<String, Object> {
8 'IsNew' => true, // The record is new
9 'IsDeleted' => false, // The record is not flagged for deletion
10 'MyField1__c' => 'Hello',
11 'MyField2__c' => 'World!'
12});
13
14// Extract the SObject
15MyRecord__c rec = (MyRecord__c) myRecord.getRecord();
16
17myRecord.isNew(); // true
18myRecord.isDeleted(); // false
19myRecord.getId(); // A temporary SFDC Id
20rec.Field1__c; // 'Hello'
21rec.Field2__c; // 'World!'TPM_Promotion.Record Methods
The following are methods for TPM_Promotion.Record.
global Boolean isDeleted
Indicates if the record is flagged for deletion or if it will be updated during
save.
API Version
55
Signature
global Boolean isDeleted()
global Boolean isNew
Indicates if the record is new or already exists in the database.
API Version
55
Signature
global Boolean isNew()
global Id getId
Returns the temporary id for the wrapped record.
Promotion save process uses temporary id’s for records that are not still committed to the
database.
API Version
55
Signature
global Id getId()
global SObject getOriginalRecord
Returns the original SObject record as stored in the database. If the record is new,
this method returns null.
API Version
55
Signature
global SObject getOriginalRecord()
global SObject getRecord
Returns the wrapped SObject record. The returned record field values can be
updated.
API Version
55
Signature
global SObject getRecord()
Example
1cgcloud.TPM_Promotion.Record myRecord;
2
3// Extract the SObject
4MyRecord__c rec = (MyRecord__c) myRecord.getRecord();
5
6// Fields can be changed and they'll be saved during promotion save
7rec.MyField1__c = 'Hello';
8rec.MyField2__c = 'World!;global void setFields
Sets the fields passed in the map as fields for the wrapped SObject record. The IsNew and IsDeleted fields will
map to the is New() and is Deleted() methods. If a key in the map is not an SObject field, it will be
ignored.
API Version
55
Signature
global void setFields(Map<String, Object> fieldValues)
Example
1cgcloud.TPM_Promotion tpmPromotion;
2
3// Append the object to create a wrapper
4cgcloud.TPM_Promotion.Record myRecord = tpmPromotion.append(new MyRecord__c());
5
6// Set field values using a Map
7myRecord.setField(new Map<String, Object> {
8 'IsNew' => true, // The record is new
9 'IsDeleted' => false, // The record is not flagged for deletion
10 'MyField1__c' => 'Hello',
11 'MyField2__c' => 'World!'
12});
13
14// Extract the SObject
15MyRecord__c rec = (MyRecord__c) myRecord.getRecord();
16
17myRecord.isNew(); // true
18myRecord.isDeleted(); // false
19myRecord.getId(); // A temporary SFDC Id
20rec.Field1__c; // 'Hello'
21rec.Field2__c; // 'World!'