Create Components in the Developer Console
The Developer Console is a convenient, built-in tool you can use to integrate data from Gospel Platform to Salesforce.
This document assumes that you have prior development experience and knowledge of other Salesforce fundamentals. Knowledge of Salesforce Developer console would be useful, but not required.
To access the Developer Console:
- In the quick access menu () > select Developer Console. The Developer Console is displayed in a separate window.
- Select File > New > Lightning Component to open a new lighting bundle panel for the Gospel component
- Enter the following details for the new lightning bundle:
- Name: Provide a name for the component
- Description: Provide a description for the component
- Component Configuration: You can select additional component configuration if required, or continue without selecting any of the options
- Click Submit to create the component.
Component bundles
You can build applications by assembling the components available in the component bundle. Please refer the Salesforce documents for more information on using the Developer Console and building the required components.
Available classes and calls for mapping objects
The following classes are supported for integrating records from record definition and view definitions.
A view definition is created in the Gospel platform by combining records from two or more record definitions and therefore are not editable. As the records in the view definition are automatically updated when the records are added or updated, the only function supported for a view definition is to get the list of records. Refer to View Definition for more information on understanding the purpose and use of view definition.
Map Objects | Class | Supported Calls |
---|---|---|
Records from Record Definition |
| Get Records from a Record Definition
|
If exists, update the list of records or insert new records
| ||
Create a record
| ||
Update a Record
| ||
Records from View Definition |
| Get List of Records from a View Definition
|
Example use cases
This section provides you with examples of the supported functions.
Load an Existing Record
The following example displays the code for getting the records from a record definition
public static List<Map<String,Object>> getOrderItemRecords() { GospelTech.certificate__c certificate = GospelTech.certificate__c.getInstance(); DataSource.ConnectionParams params = new DataSource.ConnectionParams(); params.endpoint = certificate.endpointUrl__c; params.certificateName =certificate.certName__c; GospelTech.GospelDataSourceConnection conn = new GospelTech.GospelDataSourceConnection(params); DataSource.QueryContext queryContext = new DataSource.QueryContext(); DataSource.TableSelection tableSelection = new DataSource.TableSelection(); tableSelection.tableSelected = 'orderItem'; queryContext.tableSelection = tableSelection; DataSource.TableResult result = conn.query(queryContext); return result.rows; }
Adding Records
The following example displays the code for creating records:
public static List<DataSource.UpsertResult> editOrUpdateRecord( String Id, String ChainStatus, String Discount, String FundingInPlace, String UserID, String PropertyID ) { Map<String, String> postFields = new Map<String, String>(); postFields.put('ChainStatus', ChainStatus); postFields.put('Discount', Discount); postFields.put('FundingInPlace', FundingInPlace); postFields.put('UserID', UserID); postFields.put('PropertyID', PropertyID); DataSource.UpsertContext context = new Datasource.UpsertContext(); Map<String, String> typeMap = new Map<String, String>(); typeMap.put('version', '1'); typeMap.put('name', 'UserID-fin'); Map<String, Object> recordKeyMap = new Map<String, Object>(); recordKeyMap.put('fields', postFields); recordKeyMap.put('action', 'write'); recordKeyMap.put('type', typeMap); recordKeyMap.put('id', Id); Map<String, Object> addToListMap = new Map<String,Object>(); addToListMap.put('data', JSON.serialize(recordKeyMap)); List<Map<String,Object>> recordMap = new List<Map<String,Object>>(); recordMap.Add(addToListMap); List<DataSource.UpsertResult> results = new List<DataSource.UpsertResult>(); context.TableSelected = 'POST,UserID-fin'; context.Rows = recordMap; certificate__c certificate = certificate__c.getInstance(); DataSource.ConnectionParams params = new DataSource.ConnectionParams(); params.endpoint = certificate.endpointUrl__c; params.certificateName =certificate.certName__c; GospelDataSourceConnection conn = new GospelDataSourceConnection(params); List<DataSource.UpsertResult> result = conn.upsertRows(context); return result; }
Update an Existing Record
The following example displays the code for updating an existing record in a record definition
public static List<DataSource.UpsertResult> editOrUpdateRecord( String Id, String ChainStatus, String Discount, String FundingInPlace, String UserID, String PropertyID ) { Map<String, String> postFields = new Map<String, String>(); postFields.put('ChainStatus', ChainStatus); postFields.put('Discount', Discount); postFields.put('FundingInPlace', FundingInPlace); postFields.put('UserID', UserID); postFields.put('PropertyID', PropertyID); DataSource.UpsertContext context = new Datasource.UpsertContext(); Map<String, String> typeMap = new Map<String, String>(); typeMap.put('version', '1'); typeMap.put('name', 'UserID-fin'); Map<String, Object> recordKeyMap = new Map<String, Object>(); recordKeyMap.put('fields', postFields); recordKeyMap.put('action', 'write'); recordKeyMap.put('type', typeMap); recordKeyMap.put('id', Id); Map<String, Object> addToListMap = new Map<String,Object>(); addToListMap.put('data', JSON.serialize(recordKeyMap)); addToListMap.put('id', Id); List<Map<String,Object>> recordMap = new List<Map<String,Object>>(); recordMap.Add(addToListMap); List<DataSource.UpsertResult> results = new List<DataSource.UpsertResult>(); context.TableSelected = 'PUT,UserID-fin'; context.Rows = recordMap; certificate__c certificate = certificate__c.getInstance(); DataSource.ConnectionParams params = new DataSource.ConnectionParams(); params.endpoint = certificate.endpointUrl__c; params.certificateName =certificate.certName__c; GospelDataSourceConnection conn = new GospelDataSourceConnection(params); List<DataSource.UpsertResult> result = conn.upsertRows(context); return result; }
Get Records from a View Definition
The following example displays the code for getting the records from a view definition:
public static List<Map<String,Object>> getOrderItemRecords() { GospelTech.certificate__c certificate = GospelTech.certificate__c.getInstance(); DataSource.ConnectionParams params = new DataSource.ConnectionParams(); params.endpoint = certificate.endpointUrl__c; params.certificateName =certificate.certName__c; GospelTech.GospelViewDataSourceConnection conn = new GospelTech.GospelViewDataSourceConnection(params); DataSource.QueryContext queryContext = new DataSource.QueryContext(); DataSource.TableSelection tableSelection = new DataSource.TableSelection(); tableSelection.tableSelected = 'orderItem'; queryContext.tableSelection = tableSelection; DataSource.TableResult result = conn.query(queryContext); return result.rows; }