Foundations Apex API Developer Reference

fferpcore.MessageTypeService

global with sharing class MessageTypeService

The service for interacting with Foundations fferpcore.Message Types.

Properties

Name Type Description
RETENTION_EXPIRE_IMMEDIATELY String A constant used to determine that messages can be deleted straight away.
RENENTION_NEVER_EXPIRES String A constant used to determine that messages can never be deleted.
RETENTION_WHOLE_MONTH_SUFFIX String A constant used to determine the suffix used when specifying the number of months a message can be retained for.
RETENTION_SIX_WHOLE_MONTHS String A constant used to determine how six months is displayed.

Methods

privilegedGetOrCreate

global static Map<String, fferpcore__MessageType__c> privilegedGetOrCreate(Set<String> developerNames)

This class uses a privileged operation to get or create the message types.

Input Parameters

Name Type Description
developerNames Set<String> A collection of developer names to either return or generate a message type with that developer name.

Return Value

This service returns a map of String, MessageType__c objects.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

Map<String, fferpcore.MessageType__c> messageTypes = fferpcore.MessageTypeService.privilegedGetOrCreate(new Set<String>{‘name1', 'name2'});

privilegedUpdateArchiveCutoffs

global static void privilegedUpdateArchiveCutoffs()

Update archive cutoff dates on the message types according to retention settings.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

fferpcore.RegistrationService.RegistrationRequest request = new fferpcore.RegistrationService.RegistrationRequest('developerName', 'Name', new Version(1, 0, 0));
request.addPublication('MessageTypeDeveloperName');
fferpcore.RegistrationService.registerProduct(request);

fferpcore.MessageTypeService.updateRetentionSettings(new Map<String, String>{‘MessageTypeDeveloperName' =< '6m'});

fferpcore.MessageTypeService.privilegedUpdateArchiveCutoffs();

fferpcore.MessageType__c messageType = [SELECT Id, ExpiryCutoff__c FROM fferpcore.MesageType__c WHERE DeveloperName__c = 'MessageTypeDeveloperName'];

Datetime expiryTime = messageType.ExpiryCutoff__c;

getMessageTypeTrees

global static List<fferpcore.MessageTypeTreeNode> getMessageTypeTrees()

This method returns the message type trees. There would normally be one, unless new roots have been created specifically by setting the parent to 'null' after insertion. The structure of the tree can be generated by separating parts of the developer name with '.'

Return Value

This service returns a list of MessageTypeTreeNode objects.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

fferpcore.RegistrationService.RegistrationRequest request = new fferpcore.RegistrationService.RegistrationRequest('developerName', 'Name', new Version(1, 0, 0));
request.addPublication('Parent1.Parent2.Me');
request.addPublication('Root.Me2');
fferpcore.RegistrationService.registerProduct(request);

fferpcore.MessageType__c root = [SELECT Id, Parent__c FROM fferpcore.MesageType__c WHERE DeveloperName__c = 'Root'];
root.Parent__c = null;
update root;

List<fferpcore.MessageTypeTreeNode> nodes = fferpcore.MessageTypeService.getMessageTypeTrees();

System.assertEquals(2, nodes.size());

save

global static void save(List<fferpcore.MessageTypeTreeNode> trees)

Save changes made through the fferpcore.MessageTypeTreeNode interface.

Input Parameters

Name Type Description
trees List<fferpcore.MessageTypeTreeNode> The list of message types in a tree structure as defined by the developer name and parent.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

fferpcore.RegistrationService.RegistrationRequest request = new fferpcore.RegistrationService.RegistrationRequest('developerName', 'Name', new Version(1, 0, 0));
request.addPublication('Parent1.Parent2.Me');
request.addPublication('Root.Me2');
fferpcore.RegistrationService.registerProduct(request);

fferpcore.MessageType__c root = [SELECT Id, Parent__c FROM fferpcore.MesageType__c WHERE DeveloperName__c = 'Root'];
root.Parent__c = null;
update root;

List<fferpcore.MessageTypeTreeNode> nodes = fferpcore.MessageTypeService.getMessageTypeTrees();

System.assertEquals(2, nodes.size());

//Make a change to a node.

ffeerpcore.MessageTypeService.save(nodes);

updateRetentionSettings

global static void updateRetentionSettings(Map<String, String> settings)

Update retention settings for the given developer names.

Input Parameters

Name Type Description
settings Map<String, String> A map that defines the retention setting for the given developer name. Developer name is the key.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

fferpcore.RegistrationService.RegistrationRequest request = new fferpcore.RegistrationService.RegistrationRequest('developerName', 'Name', new Version(1, 0, 0));
request.addPublication('MessageTypeDeveloperName');
fferpcore.RegistrationService.registerProduct(request);

fferpcore.MessageTypeService.updateRetentionSettings(new Map<String, String>{‘MessageTypeDeveloperName' => '6m'});

fferpcore.MessageType__c messageType = [SELECT Id, StorageExpiry__c FROM fferpcore.MesageType__c WHERE DeveloperName__c = 'MessageTypeDeveloperName'];

System.assertEquals('6m', messageType.StorageExpiry__c);
© Copyright 2009–2022 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.