ClickLink API Developer's Reference

ffirule.RuleService

global with sharing class RuleService

Service class for managing and running ClickLink Rules.

Methods

run

global static List<Id> run(List<Id> sourceRecordIds, Id ruleId)

Runs a ClickLink Rule.
Note: If the ClickLink Rule defines a Source Object Process field, any records where this field value is false will be skipped when the Rule runs. Similarly, if a Source Object Processed field is defined, any record where this field value is true will be skipped.

Input Parameters

Name Type Description
sourceRecordIds List<Id> The IDs of the source records to be processed.
ruleId Id The ID of the ClickLink Rule.

Return Value

List of newly created target record IDs.

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.

Id ruleId = 'a0L2000000XICEr';
List<Account> accounts = [SELECT Id FROM Account WHERE Name = 'Example Account'];
Set<Id> accountIds = new Map<Id, SObject>(accounts).keySet();

List<Id> targetIds = ffirule.RuleService.run(new List<Id>(accountIds), ruleId);

run

global static List<Id> run(List<Id> sourceRecordIds, String actionName, Boolean updateFeed)

Runs a ClickLink Rule.
Note: If the ClickLink Rule defines a Source Object Process field, any records where this field value is false will be skipped when the Rule runs. Similarly, if a Source Object Processed field is defined, any record where this field value is true will be skipped.

Input Parameters

Name Type Description
sourceRecordIds List<Id> The IDs of the source records to be processed.
actionName String The name of the ClickLink Action for the ClickLink Rule.
updateFeed Boolean Whether or not to update the Chatter feed.

Return Value

List of newly created target record IDs.

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.

String actionName = 'Example action';
List<Account> accounts = [SELECT Id FROM Account WHERE Name = 'Example Account'];
Set<Id> accountIds = new Map<Id, SObject>(accounts).keySet();

List<Id> targetIds = ffirule.RuleService.run(new List<Id>(accountIds), actionName, true);

resolveActions

global static Map<SObjectType, List<ffirule.RuleService.Action>> resolveActions(Map<SObjectType, List<String>> sourceObjectActions)

Retrieves ClickLink Actions for the supplied names.

Input Parameters

Name Type Description
sourceObjectActions Map<SObjectType, List<String>> Action names, keyed by the SObjectType they relate to.

Return Value

RuleService.Action objects, keyed by the SObjectType they relate to.

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<Schema.SObjectType, List<String>> actionNamesByObjectType = new Map<Schema.SObjectType, List<String>>{
    Account.SObjectType => new List<String>{ 'Example Action 1', 'Example Action 2' }
};

Map<Schema.SObjectType, List<ffirule.RuleService.Action>> actions = ffirule.RuleService.resolveActions(actionNamesByObjectType);

clone

global static List<Id> clone(List<Id> ruleIds)

Creates new ClickLink Rules by cloning existing ClickLink Rules and adding Clone to names of the newly created Rules. The existing Rules' Mappings, Relationships and detail-level Rules are also cloned.
Note: ClickLink will not add the Clone suffix when cloning a ClickLink Rule whose name already ends in Clone. Therefore, we recommend you change the default name of cloned rules before cloning them again.

Input Parameters

Name Type Description
ruleIds List<Id> The IDs of the ClickLink Rules to copy.

Return Value

List of newly created ClickLink Rule IDs.

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.

List<ffirule__IntegrationRule__c> rules = [SELECT Id FROM ffirule__IntegrationRule__c WHERE Name = 'Example Rule'];
Set<Id> ruleIds = new Map<Id, SObject>(rules).keySet();
List<Id> clonedRuleIds = ffirule.RuleService.clone(new List<Id>(ruleIds));

createMappings

global static List<Id> createMappings(List<ffirule.RuleService.CreateMappingInfo> createMappingInfos)

Create ClickLink Mappings.

Input Parameters

Name Type Description
createMappingInfos List<ffirule.RuleService.CreateMappingInfo> CreateMappingInfos describing the mappings.

Return Value

List of newly created ClickLink Mapping IDs.

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.

ffirule.RuleService.CreateMappingInfo mapping = new ffirule.RuleService.CreateMappingInfo();
mapping.RuleId = 'a0I2000000DcfMX';
mapping.SourceField = c2g__WorkOrder__c.Id.getDescribe().getName();
mapping.TargetField = c2g__CodaInvoice__c.c2g__WorkOrder__c.getDescribe().getName();

List<ffirule.RuleService.CreateMappingInfo> mappings = new List<ffirule.RuleService.CreateMappingInfo>{mapping};
List<Id> actualMappingIds = ffirule.RuleService.createMappings(mappings);

ffirule.RuleService.CreateMappingInfo

global class CreateMappingInfo

Describes a ClickLink Mapping.

Properties

Name Type Description
RuleId Id The ID of the rule this mapping relates to.
SourceField String The API name of the source SObjectField this mapping relates to.
TargetField String The API name of the target SObjectField this mapping relates to.

ffirule.RuleService.Action

global class Action

Describes a ClickLink Action.

Properties

Name Type Description
RuleId Id The ID of the ClickLink Rule for this ClickLink Action.
ActionName String The name of the ClickLink Action.
ActionMessage String The message describing the ClickLink Action.
FeedLinkMessage String The static message displayed in the Chatter feed with a link to the target record.
FeedMessage String The static message displayed in the Chatter feed.
FeedLinkMessageTarget String The API name of the field containing a dynamic message to display in the Chatter feed with a link to the target record.
FeedMessageTarget String The API name of the field containing a dynamic message to display in the Chatter feed.