Create the Callout Step in DRO - Salesfroce - Dynamic Revenue Orchestrator
To create "CallOut" action in DRO steps :
To create callout we need to create "Integration Definitions"
setup -> Integration Definitions on search -> create new ->
Once you click on save it will redirect to this page
Step1 : Create Class like
global with sharing class CustomFulfillmentProvider implements industriesintegrationfwk.ServiceIntegrationProvider {
// 1. Primary synchronous invocation logic
global industriesintegrationfwk.IntegrationCalloutResponse invokeMethod(String method, Map<String,Object> inputMap) {
industriesintegrationfwk.IntegrationCalloutResponse response = new industriesintegrationfwk.IntegrationCalloutResponse(true);
try {
// STEP A: Extract the Orchestration Record Context IDs from the framework map
String targetRecordId = '';
if (inputMap != null && inputMap.containsKey('fulfillmentStepContextIds')) {
List<Object> contextIds = (List<Object>) inputMap.get('fulfillmentStepContextIds');
if (contextIds != null && !contextIds.isEmpty()) {
targetRecordId = String.valueOf(contextIds[0]); // Captures the context ID (e.g., Quote, Order, or Asset Line Item)
}
}
// STEP B: Pass the extracted dynamic record ID down to your callout method
String calloutResponseBody = makeVSRCallout(targetRecordId);
// Deserialize the JSON body string into a Map structure required by the framework
Map<String, Object> parsedResponseMap = (Map<String, Object>) JSON.deserializeUntyped(calloutResponseBody);
response.setReturnValue(parsedResponseMap);
} catch (Exception e) {
response = new industriesintegrationfwk.IntegrationCalloutResponse(false);
response.setErrorMessage('Integration execution failed: ' + e.getMessage());
}
return response;
}
/**
* Core secure Named Credential callout logic accepting a dynamic context filter
*/
private static String makeVSRCallout(String contextId) {
HttpRequest req = new HttpRequest();
// STEP C: Construct a dynamic SOQL query filter string based on the context payload availability
String queryStr = 'SELECT Id, Name, Status__c FROM OrderItem LIMIT 10'; // Default query fallback
if (String.isNotBlank(contextId)) {
// Adjust this condition dynamically based on whether you are querying by QuoteId, OrderId, or specific Line Item Id
queryStr = 'SELECT Id, Name, Status__c FROM OrderItem WHERE Id = \'' + String.escapeSingleQuotes(contextId) + '\'';
}
req.setEndpoint(
'callout:VSR_API/services/data/v65.0/query?q=' +
EncodingUtil.urlEncode(queryStr, 'UTF-8')
);
req.setMethod('GET');
req.setHeader('Content-Type', 'application/json');
System.debug('req.getEndpoint() : ' + req.getEndpoint());
Http http = new Http();
HttpResponse res = http.send(req);
if (res.getStatusCode() == 200) {
return res.getBody();
}
throw new CalloutException(
'HTTP Error Code: ' + res.getStatusCode() + ' | Body: ' + res.getBody()
);
}
// 2. Asynchronous registration structure signature
global industriesintegrationfwk.IntegrationCalloutRequest getCalloutRequest(String requestId, Map<String, Object> params, Map<String, Object> attributes) {
return null;
}
// 3. Framework post-processing continuation signature
global industriesintegrationfwk.IntegrationCalloutResponse getCalloutResponse(List<HttpResponse> httpResponseList, Object state, Map<String, Object> attributes) {
return null;
}
// 4. Specified framework metadata type array
global List<industriesintegrationfwk.ApexProviderAttr> getProviderAttributes() {
List<industriesintegrationfwk.ApexProviderAttr> attributes = new List<industriesintegrationfwk.ApexProviderAttr>();
// Use the parameterized constructor: (Label, Name, Default Value, Is Required, Data Type)
industriesintegrationfwk.ApexProviderAttr dummyAttr = new industriesintegrationfwk.ApexProviderAttr(
'Status Mapping',
'Status',
'Default',
false,
'String'
);
attributes.add(dummyAttr);
return attributes;
}
}
=========================================================================
Comments
Post a Comment