Writing an Apex Class
🔸 Example Code
global class DataSourceInventory implements SBLS.DataSourceService.Fetchable {
global SBLS.DataSourceService.Result execute(SBLS.DataSourceService.Parameter params) {
// Retrieve records from the List
List<SObject> records = params.gets();
// Fetch DataSource values (e.g., inventory data) from an external API
Map<String, Integer> inventoryData = new Map<String, Integer>();
inventoryData.put('Product001', 10);
inventoryData.put('Product002', 20);
// Create the Result object
SBLS.DataSourceService.Result result = new SBLS.DataSourceService.Result();
// Map DataSource values to List records
for (String productCode : inventoryData.keySet()) {
SBLS.DataSourceService.Action action = new SBLS.DataSourceService.Action();
action.setKeyValue(productCode); // Set the Key value for mapping
action.putSourceToTargetField(
inventoryData.get(productCode), // DataSource value: inventory
'SBLS_Virtual1' // Virtual column API name
);
result.addAction(action); // Add Action to the Result
}
return result; // Return the final Result
}
}🔸 SBLS.DataSourceService.Parameter
Example Code
Method
🔸 SBLS.DataSourceService.Result
Example Code
Method
Parameter
Type
Value
🔸 SBLS.DataSourceService.Action
Example Code
Method
Parameter
Type
Value
Parameter
Type
Value
Last updated