forcedotcom/sf-skills / skills/omnistudio-callable-apex-generate
omnistudio-callable-apex-generate
VerifiedSalesforce Industries Common Core (OmniStudio/Vlocity) Apex callable generation and review skill with 120-point scoring. Use when creating, reviewing, or migrating Industries callable Apex implementations. TRIGGER when: user creates or reviews System.Callable classes, migrates VlocityOpenInterface or VlocityOpenInterface2, or builds Industries callable extensions used by OmniStudio, Integration Procedures, or DataRaptors. DO NOT TRIGGER when: generic Apex classes or triggers (use platform-apex-generate), building Integration Procedures (use omnistudio-integration-procedure-generate), authoring OmniScripts (use omnistudio-omniscript-generate), configuring Data Mappers (use omnistudio-datamapper-generate), or analyzing namespace/dependency issues (use omnistudio-dependencies-analyze).
examples/Test_VlocityOpenInterface2Conversion/MyCustomCallable.cls
View on GitHub/**
* @description Callable implementation for calculateTotal (converted from VlocityOpenInterface2).
* Accepts price and quantity from inputMap, returns total in response envelope.
* Original: MyCustomRemoteClass implements omnistudio.VlocityOpenInterface2.
* @author building-omnistudio-callable-apex
*/
public with sharing class MyCustomCallable implements System.Callable {
public Object call(String action, Map<String, Object> args) {
Map<String, Object> inputMap = (args != null && args.containsKey('inputMap'))
? (Map<String, Object>) args.get('inputMap') : (args != null ? args : new Map<String, Object>());
Map<String, Object> options = (args != null && args.containsKey('options'))
? (Map<String, Object>) args.get('options') : new Map<String, Object>();
if (inputMap == null) { inputMap = new Map<String, Object>(); }
if (options == null) { options = new Map<String, Object>(); }
switch on action {
when 'calculateTotal' {
return calculateTotal(inputMap, options);
}
when else {
throw new IndustriesCallableException('Unsupported action: ' + action);
}
}
}
private Map<String, Object> calculateTotal(Map<String, Object> inputMap, Map<String, Object> options) {
Decimal price = toDecimal(inputMap.get('price'));
Integer qty = toInteger(inputMap.get('quantity'));
if (price == null || qty == null) {
return new Map<String, Object>{
'success' => false,
'data' => new Map<String, Object>(),
'errors' => new List<Map<String, Object>>{
new Map<String, Object>{
'code' => 'INVALID_INPUT',
'message' => 'price and quantity are required and must be numeric'
}
}
};
}
Decimal total = price * qty;
return new Map<String, Object>{
'success' => true,
'data' => new Map<String, Object>{ 'total' => total },
'errors' => new List<Map<String, Object>>()
};
}
private Decimal toDecimal(Object o) {
if (o == null) return null;
if (o instanceof Decimal) return (Decimal) o;
if (o instanceof Integer) return Decimal.valueOf((Integer) o);
if (o instanceof Double) return Decimal.valueOf((Double) o);
if (o instanceof String) {
try { return Decimal.valueOf((String) o); } catch (TypeException e) { return null; }
}
return null;
}
private Integer toInteger(Object o) {
if (o == null) return null;
if (o instanceof Integer) return (Integer) o;
if (o instanceof Long) return ((Long) o).intValue();
if (o instanceof Decimal) return ((Decimal) o).intValue();
if (o instanceof String) {
try { return Integer.valueOf((String) o); } catch (TypeException e) { return null; }
}
return null;
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |