This page provides information about the globally exposed Apex classes
in Scientific Publications Cloud that you can reference and use.
Document Service
The Document Service (CM_DocumentService) Apex class clones an existing
Document Version
(mvn__CM_Document_Version__c) record, together with the parent
Document (mvn__CM_Document__c), its
Document Regions
(mvn__CM_Document_Region__c), and its
Document Relationships
(mvn__CM_Document_Relationship__c). Use it to build your own clone
functionality when the packaged Document clone
framework does not fit your
process.
global with sharing class CM_DocumentService implements CM_IDocumentService
The method clones the document and its document version, and creates the regions and
document relationships supplied in the corresponding parameters. It doesn't run the
Scientific Publications Cloud related-records clone, so none of the following wizard-managed records are copied:
- Collaborators
- Document Roles
- Studies
- Objectives
- Targets
Records of custom objects related to the document aren't copied either. If your
process needs any related records, create them from the returned document record.
Method(s)
cloneDocument(documentVersion, regions, relationships, contentDocumentId)
global static mvn__CM_Document_Version__c cloneDocument(mvn__CM_Document_Version__c documentVersion,
List<mvn__CM_Document_Region__c> regions,
List<mvn__CM_Document_Relationship__c> relationships,
String contentDocumentId)
-
Description: This method clones a document version and returns the new record so that you can run your own processing afterwards. It runs in the sharing context of the calling user, so the clone respects the permissions and sharing rules that apply to that user. If the clone fails, the method throws a CM_DocumentServiceException that wraps the original exception.
-
Returns: mvn__CM_Document_Version__c
| Parameter | Type | Description |
|---|
| documentVersion | mvn__CM_Document_Version__c | The Document Version (mvn__CM_Document_Version__c) record to copy, with any field overrides already applied. Fields you set on this record are used on the clone instead of the source values. |
| regions | List<mvn__CM_Document_Region__c> | The Document Region (mvn__CM_Document_Region__c) records to create on the cloned document. Pass an empty list to create no regions. |
| relationships | List<mvn__CM_Document_Relationship__c> | The Document Relationship (mvn__CM_Document_Relationship__c) records to create on the cloned document. Pass an empty list to create no relationships. |
| contentDocumentId | String | The Id of the ContentDocument record that holds the file for the new version. |
The following example clones a document version, overrides the title, and
then creates a related record of its own on the clone:
mvn__CM_Document_Version__c source = [
SELECT mvn__CM_Title__c, mvn__CM_Document__c
FROM mvn__CM_Document_Version__c
WHERE Id = :sourceVersionId
];
source.mvn__CM_Title__c = source.mvn__CM_Title__c + ' (copy)';
mvn__CM_Document_Version__c clone = mvn.CM_DocumentService.cloneDocument(
source,
new List<mvn__CM_Document_Region__c>(),
new List<mvn__CM_Document_Relationship__c>(),
contentDocumentId
);
insert new mvn__PP_Publication_Objective__c(
mvn__PP_Publication__c = clone.mvn__CM_Document__c,
Name = 'Primary objective'
);
Call the method from a context that allows DML, and handle
CM_DocumentServiceException so that your process can report the failure
and clean up. If your process deletes a clone that failed partway through,
reference Automatic cleanup of failed clones.
Notification Log Service
The Notification Log Service (SE_NotificationLogService) Apex class
creates notification logs
(mvn__SE_Notification_Log__c) records for all emails and Salesforce
notifications that are sent out regardless of the user's sharing rules.
This can be used to create notification logs for any activities that are
not part of Scientific Publications Cloud.
global without sharing class SE_NotificationLogService implements SE_INotificationLogService
Method(s)
logEmailMessages(emails, results)
global void logEmailMessages(List\<Messaging.SingleEmailMessage\> emails, List\<Messaging.SendEmailResult\> results)
| Description | This method logs the emails that were sent out and their delivery statuses. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| emails | List<Messaging.SingleEmailMessage> | The list of standard Single Email Message (Messaging.SingleEmailMessage) records to be logged. These contain the content of the emails that were sent. |
| results | List<Messaging.SendEmailResult> | The list of standard Send Email Result (Messaging.SendEmailResult) records to be logged. These contain the delivery statuses of the emails that were sent (i.e., whether or not an email was sent successfully). |
logNotifications(notifications, errorMessage)
global void logNotifications(List\<SE_SalesforceNotification\> notifications, String errorMessage)
| Description | This method logs the Salesforce notifications that were sent out as well as any corresponding error messages. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| notifications | List<SE_SalesforceNotification> | The list of Salesforce Notification (SE_SalesforceNotification) instances to log. |
| errorMessage | String | The error that was thrown when the Salesforce notification was sent, if any. |
Salesforce Notification
The Salesforce Notification (SE_SalesforceNotification) Apex class
represents Salesforce notifications for custom system events.
global with sharing class SE_SalesforceNotification extends SE_Message
Accessor(s)
global Id customNotificationTypeId
Constructor
global SE_SalesforceNotification (Id recipientId,
Id primaryRecordId,
String body,
String subject,
Id customNotificationTypeId)
| Description | A constructor to create a Salesforce notification for a custom system event. |
|---|
| Parameter | Type | Description |
|---|
| recipientId | Id | The ID of the User record that represents the recipient of the notification. |
| primaryRecordId | Id | The ID of the target record of the notification. |
| body | String | The body of the notification. |
| subject | String | The subject of the notification. |
| customNotificationTypeId | Id | The ID of the notification for the custom system event. |
Dynamic Trigger Handler
The Dynamic Trigger Handler (TAF_DynamicTriggerHdlr) Apex class
exposes the methods for configuring the
Trigger Action Framework.
global inherited sharing class TAF_DynamicTriggerHdlr
Constructor
TAF_DynamicTriggerHdlr()
global TAF_DynamicTriggerHdlr()
| Description | An empty constructor that allows the run(key) method to be called. |
|---|
Method(s)
global static void addMetadataTriggerHandlerBypass(String triggerActionName)
| Description | This method bypasses a specific trigger action during a transaction. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| triggerActionName | String | The API name of the Trigger Action (mvn__TAF_Trigger_Action__mdt) metadata record to bypass. |
addTriggerActionFlowBypass(flowName)
global static void addTriggerActionFlowBypass(String flowName)
| Description | This method bypasses a specific flow during a transaction. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| flowName | String | The API name of the flow to bypass. |
addTriggerBaseBypass(sObjectName)
global static void addTriggerBaseBypass(String sObjectName)
| Description | This method bypasses the trigger execution of a given sObject. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| sObjectName | String | The API name of the sObject to bypass the trigger on. |
global static void clearMetadataTriggerHandlerBypass(String triggerActionName)
| Description | This method clears the bypass flag for a specific trigger action. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| triggerActionName | String | The API name of the Trigger Action (mvn__TAF_Trigger_Action__mdt) metadata record to no longer bypass and to execute instead. |
clearTriggerActionFlowBypass(flowName)
global static void clearTriggerActionFlowBypass(String flowName)
| Description | This method clears the bypass flag for a specific flow. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| flowName | String | The API name of the flow to no longer bypass and to execute instead. |
clearTriggerBaseBypass(sObjectName)
global static void clearTriggerBaseBypass(String sObjectName)
| Description | This method clears the bypass flag for a given sObject. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| sObjectName | String | The API name of the sObject to no longer bypass and to execute the trigger on instead. |
getIdToNumberOfTimesSeenAfterUpdate()
global static Map\<Id, Integer\> getIdToNumberOfTimesSeenAfterUpdate()
| Description | This method returns a map of the context record IDs to the number of times they've been operated on in the AFTER UPDATE context. You can use this method to check the number of times the trigger has processed the records and therefore if the trigger is running recursively but cannot use this method to stop a recursion. |
|---|
| Returns | Map<Id, Integer> |
getIdToNumberOfTimesSeenBeforeUpdate()
global static Map\<Id, Integer\> getIdToNumberOfTimesSeenBeforeUpdate()
| Description | This method returns a map of the context record IDs to the number of times they've been operated on in the BEFORE UPDATE context. You can use this method to check the number of times the trigger has processed the records and therefore if the trigger is running recursively but cannot use this method to stop a recursion. |
|---|
| Returns | Map<Id, Integer> |
run(key)
global void run(String key)
| Description | This method is called from the trigger and initiates a new run. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| key | String | The name of the trigger handler. |
Trigger Action Interfaces
The Trigger Action (TAF_TriggerAction) Apex class collects the
available interfaces when implementing a trigger for the
Trigger Action Framework.
global class TAF_TriggerAction
Interface(s)
BeforeInsert
implements mvn.TAF_TriggerAction.BeforeInsert {
void beforeInsert(List<SObject> newList);
}
| Description | This interface allows the class to be used in a Before Insert context. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| newList | List<SObject> | The records from Trigger.new |
AfterInsert
implements mvn.TAF_TriggerAction.AfterInsert {
void afterInsert(List<SObject> newList);
}
| Description | This interface allows the class to be used in an After Insert context. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| newList | List<SObject> | The records from Trigger.new |
BeforeUpdate
implements mvn.TAF_TriggerAction.BeforeUpdate {
void beforeUpdate(List<SObject> newList, List<SObject> oldList);
}
| Description | This interface allows the class to be used in a Before Update context. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| newList | List<SObject> | The records from Trigger.new |
| oldList | List<SObject> | The records from Trigger.old |
AfterUpdate
implements mvn.TAF_TriggerAction.AfterUpdate {
void afterUpdate(List<SObject> newList, List<SObject> oldList);
}
| Description | This interface allows the class to be used in an After Update context. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| newList | List<SObject> | The records from Trigger.new |
| oldList | List<SObject> | The records from Trigger.old |
BeforeDelete
implements mvn.TAF_TriggerAction.BeforeDelete {
void beforeDelete(List<SObject> oldList);
}
| Description | This interface allows the class to be used in a Before Delete context. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| oldList | List<SObject> | The records from Trigger.old |
AfterDelete
implements mvn.TAF_TriggerAction.AfterDelete {
void afterDelete(List<SObject> oldList);
}
| Description | This interface allows the class to be used in an After Delete context. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| oldList | List<SObject> | The records from Trigger.old |
AfterUndelete
implements mvn.TAF_TriggerAction.AfterUndelete {
void afterUndelete(List<SObject> newList);
}
| Description | This interface allows the class to be used in an After Undelete context. |
|---|
| Returns | void |
| Parameter | Type | Description |
|---|
| newList | List<SObject> | The records from Trigger.new |