Accounting API Developer's Reference

c2g.CommonService

global with sharing class CommonService

Encapsulates all service layer logic for Common functionality. For more guidelines and details see https://developer.salesforce.com/page/Apex_Enterprise_Patterns_-_Service_Layer

Enums

TransactionType

The different possible transaction types

Methods

lookup

global static List<c2g.CommonService.Identity> lookup(String targetObject, String namePrefix)

Retrieves all indentities of the given object

Input Parameters

Name Type Description
targetObject String The name of the object
namePrefix String The query string to match to

Return Value

This service returns a list of c2g.CommonService.Identity objects.

selectIdentitiesByIds

global static List<c2g.CommonService.Identity> selectIdentitiesByIds(String targetObject, Set<ID> ids)

Retrieves indentities of the given object with ids in given ids

Input Parameters

Name Type Description
targetObject String The name of the object
ids Set<ID> The ids of the instances of the object

Return Value

This service returns a list of c2g.CommonService.Identity objects.

lookupChildrenByParentIds

global static List<c2g.CommonService.Identity> lookupChildrenByParentIds(String childObject, String parentFieldName, Set<ID> ids)

Retrieves indentities of the given object with parent id in given ids

Input Parameters

Name Type Description
childObject String The name of the child object
parentFieldName String The field name of the parent relationship on the object
ids Set<ID> The ids of the parent instances

Return Value

This service returns a list of c2g.CommonService.Identity objects.

getObjectList

global static List<String> getObjectList()

Retrieves a list of all sObjects in the org

Return Value

This service returns a list of object names as strings

getObjectMetadata

global static Map<String, c2g.CommonService.ObjectMetadata> getObjectMetadata(Set<String> objects, Boolean throwException, Boolean getAllFields)

Retrieves metadata for given objects

Input Parameters

Name Type Description
objects Set<String> The objects you require metadata for
throwException Boolean Whether to ignore or throw exceptions for invalid objects
getAllFields Boolean Whether to include all field types or exclude composite fields (such as ADDRESS)

Return Value

This service returns a map of object name (string) to the metadata.

getObjectMetadata

global static Map<String, c2g.CommonService.ObjectMetadata> getObjectMetadata(Set<String> objects, Boolean throwException, Boolean getAllFields, Boolean getLookups)

Retrieves metadata for given objects

Input Parameters

Name Type Description
objects Set<String> The objects you require metadata for
throwException Boolean Whether to ignore or throw exceptions for invalid objects
getAllFields Boolean Whether to include all field types or exclude composite fields (such as ADDRESS)
getLookups Boolean Whether to include lookups in the returned metadata

Return Value

This service returns a map of object name (string) to the metadata.

getObjectMetadata

global static Map<String, c2g.CommonService.ObjectMetadata> getObjectMetadata(Set<String> objects, Boolean throwException)

Retrieves metadata for given objects

Input Parameters

Name Type Description
objects Set<String> The objects you require metadata for
throwException Boolean Whether to ignore or throw exceptions for invalid objects

Return Value

This service returns a map of object name (string) to the metadata.

getPicklistOptions

global static List<c2g.CommonService.Picklist> getPicklistOptions(Schema.DescribeFieldResult picklistField)

Retrieves the picklist information for a field

Input Parameters

Name Type Description
objects null The field describe result of the picklist field

Return Value

This service returns a list of c2g.CommonService.Picklist objects.

c2g.CommonService.ObjectMetadata

global class ObjectMetadata

Stores salesforce SObject metadata

Properties

Name Type Description
objectName String Name of the SObject
fieldMap Map<String, c2g.CommonService.Field> Holds the details of the fields on the object
lookupMap Map<String, c2g.CommonService.Field> Holds the details of the lookups on the object
relationshipMap Map<String, c2g.CommonService.Relationship> Holds the details of the relationships on the object

c2g.CommonService.Field

global class Field

Stores metadata for a salesforce field

Properties

Name Type Description
fieldName String Name of the field
fieldLabel String Label of the field
fieldType String Type of the field
fieldSOAPType String Soap type of the field
fieldPrecision Integer For fields of Type 'Double' this will store the precision of the field. (The maximum number of digits that can be stored, including all numbers to the left and to the right of the decimal point)
fieldScale Integer For fields of Type 'Double' this will store the scale of the field. (The number of digits to the right of the decimal point)
lookupObject String The name of the parent object for this field if this field is a lookup
picklist List<c2g.CommonService.Picklist> Holds the picklist information if the field is a picklist
isFilterable Boolean When True, indicates that the field can be used as part of the filter criteria of a WHERE statement.

c2g.CommonService.Relationship

global class Relationship

Holds information about a relationship on a field

Properties

Name Type Description
relationshipName String Name of the relationship
objectName String Name of Object the relationship is to
objectLabel String Label of Object the relationship is to

c2g.CommonService.Picklist

global class Picklist

Holds picklist information for picklist fields

Properties

Name Type Description
Name String The name of the picklist value
Label String The label of the picklist value

c2g.CommonService.Identity

global class Identity

Hold identity information for an entity

Properties

Name Type Description
Id Id The Id of the entity
Name String The name of the entity

Methods

Identity

global Identity(ID anId)

Creates an API version of an Identity.

Input Parameters

Name Type Description
key null An Id for the Identity.

Identity

global Identity(ID anId, String aName)

Creates an API version of an Identity.

Input Parameters

Name Type Description
anId ID An Id for the Identity.
aName String A name for the Identity.

hashCode

global Integer hashCode()

Gets the Hash code of the Identity.

Return Value

The hash code using the Id or in the case of an identity without an Id the Name is used

equals

global Boolean equals(Object obj)

Checks whether the Identity represents a given object.

Input Parameters

Name Type Description
obj Object The object to check.

Return Value

The boolean result of the equality check