Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Invoke Underwriting Rules Action
This action is available in API version 65.0 and later.
Supported REST HTTP Methods
- URI
- /services/data/v68.0/actions/standard/invokeUnderwritingRules
- Formats
- JSON
- HTTP Methods
- POST
- Authentication
- Authorization: Bearer token
Inputs
| Input | Details |
|---|---|
| invokeUnderwritingRuleInputRep |
|
Outputs
| Output | Details |
|---|---|
| invokeUnderwritingRuleOputRep |
|
Example
Sample Request
1{
2 "inputs": [
3 {
4 "invokeUnderwritingRuleInputRep": {
5 "objectId": "0Zkxx000000001qCAA",
6 "toStage": "Open"
7 }
8 }
9 ]
10}This is a sample request to call this invocable action from Apex code.
1public class InsuranceUnderwritingRuleApexService implements Callable {
2
3 private static final String METHOD_INVOKE_UW_RULE = 'invokeUnderwritingRule';
4 private static final String OUTPUT_NAME = 'invokeUnderwritingRuleOputRep';
5
6 /**
7 * @description Implementation of Callable interface for OmniStudio
8 * @param action Method name to invoke
9 * @param args Map containing input, output, and options
10 * @return Object result of the method invocation
11 */
12 public Object call(String action, Map<String, Object> args) {
13 System.debug('InsuranceQuoteApexService: call ' + action);
14 Boolean response = false;
15 Map<String, Object> input = (Map<String, Object>) args.get('input');
16 Map<String, Object> output = (Map<String, Object>) args.get('output');
17 Map<String, Object> options = (Map<String, Object>) args.get('options');
18
19 if (METHOD_INVOKE_UW_RULE.equals(action)) {
20 if (!input.containsKey('objectId') || input.get('objectId') == null) {
21 throw new IllegalArgumentException('objectId is missing or null');
22 }
23 if (!input.containsKey('toStage') || input.get('toStage') == null) {
24 throw new IllegalArgumentException('toStage is missing or null');
25 }
26 String objectId = (String)input.get('objectId');
27 String toStage = (String)input.get('toStage');
28 Object ruleResult = invokeUWRules(objectId, toStage);
29 output.put('ruleResult', ruleResult);
30 response = true;
31 }
32 return response;
33 }
34
35 public static Object invokeUWRules(String objectId, String toStage) {
36 System.debug('InsuranceUnderwritingRuleApexService: objectId:' + objectId + ', toStage : ' + toStage);
37
38 Object outputRep;
39
40 try {
41
42
43 System.debug('Calling Invocable Action: invokeUnderwritingRules');
44
45 // Create and configure the invocable action
46 Invocable.Action action = Invocable.Action.createStandardAction('invokeUnderwritingRules');
47
48 // Set required invocation parameters
49 ConnectApi.invokeUnderwritingRuleInputRep inputRep = new ConnectApi.invokeUnderwritingRuleInputRep();
50 inputRep.objectId = objectId;
51 inputRep.toStage = toStage;
52 action.setInvocationParameter('invokeUnderwritingRuleInputRep', inputRep);
53
54 // Execute the action
55 List<Invocable.Action.Result> results = action.invoke();
56
57 if (results != null && !results.isEmpty()) {
58 Invocable.Action.Result result = results[0];
59
60 if (result.isSuccess()) {
61 System.debug('Invoke UW Rule successfully from Invocable Action');
62 // Extract key information from the result
63 Map<String, Object> outputParams = result.getOutputParameters();
64 if (outputParams != null) {
65 outputRep = outputParams.get(OUTPUT_NAME);
66 System.debug('output: ' + JSON.serialize(outputRep));
67
68 return outputRep;
69 }
70 } else {
71 System.debug('invoke UW Rule fail: ' + result);
72 return result.getErrors();
73 }
74 }
75
76 } catch (Exception e) {
77 throw e;
78 }
79 return outputRep;
80 }
81}Sample Response
1[
2 {
3 "actionName": "invokeUnderwritingRules",
4 "errors": null,
5 "invocationId": null,
6 "isSuccess": true,
7 "outcome": null,
8 "outputValues": {
9 "invokeUnderwritingRuleOputRep": {
10 "objectId": "0Zkxx000000001qCAA",
11 "objectName": "Claim",
12 "fromStage": "Draft",
13 "toStage": "Open",
14 "stageTransitionName": "Draft to Open",
15 "stageTransitionUnderwritingEvaluationId": "1Mjxx00000004C0CA2",
16 "isSuccess": true,
17 "rulesetResults": [
18 {
19 "productId": "01tSM000005OFyGYAW",
20 "evaluationCriteria": "1 OR 2",
21 "isSuccess": true,
22 "ruleResults": [
23 {
24 "ruleApiName": "CollisionRule",
25 "isSuccess": true
26 },
27 {
28 "ruleApiName": "AutoSilverRule",
29 "isSuccess": true
30 }
31 ]
32 },
33 {
34 "productId": "01tSM000005OFyJYAW",
35 "evaluationCriteria": "1",
36 "isSuccess": true,
37 "ruleResults": [
38 {
39 "ruleApiName": "MedicalRule1",
40 "isSuccess": true
41 }
42 ]
43 }
44 ]
45 }
46 },
47 "sortOrder": -1,
48 "version": 1
49 }
50]