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_QuoteByProductCallable/Industries_QuoteByProductCallable.cls
View on GitHub/**
* @description Industries callable that finds Quotes on an Account that have at least one
* QuoteLineItem with a specified Product2.ProductCode.
* Integrates with OmniStudio/Industries extension points.
* @author building-omnistudio-callable-apex
*
* Actions:
* - findQuotesByProductCode: Returns Quotes for an Account with QuoteLineItems matching productCode
*
* Input (findQuotesByProductCode):
* - accountId (String, required): Id of the Account
* - productCode (String, required): Product2.ProductCode to match on QuoteLineItems
*
* Output envelope:
* - success (Boolean)
* - data (Map): quotes (List<Map> with Id, Name, QuoteNumber)
* - errors (List<Map>)
*/
public with sharing class Industries_QuoteByProductCallable implements System.Callable {
private static final String ACTION_FIND_QUOTES = 'findQuotesByProductCode';
/**
* @description Dispatches to the appropriate action handler.
* @param action Action name (e.g. 'findQuotesByProductCode')
* @param args Input map with accountId and productCode
* @return Response envelope: success, data, errors
*/
public Object call(String action, Map<String, Object> args) {
switch on action {
when ACTION_FIND_QUOTES {
return findQuotesByProductCode(args);
}
when else {
throw new IndustriesCallableException('Unsupported action: ' + action);
}
}
}
/**
* @description Finds all Quotes on an Account that have at least one QuoteLineItem
* with the specified Product2.ProductCode.
* @param args Map with keys: accountId (String), productCode (String)
* @return Response envelope with quotes list or errors
*/
private Map<String, Object> findQuotesByProductCode(Map<String, Object> args) {
List<Map<String, Object>> errors = new List<Map<String, Object>>();
Object accountIdObj = args != null ? args.get('accountId') : null;
Object productCodeObj = args != null ? args.get('productCode') : null;
String accountId = accountIdObj != null ? String.valueOf(accountIdObj).trim() : null;
String productCode = productCodeObj != null ? String.valueOf(productCodeObj).trim() : null;
if (String.isBlank(accountId)) {
errors.add(new Map<String, Object>{
'code' => 'MISSING_ACCOUNT_ID',
'message' => 'accountId is required'
});
}
if (String.isBlank(productCode)) {
errors.add(new Map<String, Object>{
'code' => 'MISSING_PRODUCT_CODE',
'message' => 'productCode is required'
});
}
if (!errors.isEmpty()) {
return new Map<String, Object>{
'success' => false,
'data' => new Map<String, Object>{ 'quotes' => new List<Map<String, Object>>() },
'errors' => errors
};
}
try {
List<Quote> quotes = [
SELECT Id, Name, QuoteNumber, OpportunityId
FROM Quote
WITH USER_MODE
WHERE Opportunity.AccountId = :accountId
AND Id IN (
SELECT QuoteId
FROM QuoteLineItem
WHERE Product2.ProductCode = :productCode
)
];
List<Map<String, Object>> quoteMaps = new List<Map<String, Object>>();
for (Quote q : quotes) {
quoteMaps.add(new Map<String, Object>{
'Id' => q.Id,
'Name' => q.Name,
'QuoteNumber' => q.QuoteNumber
});
}
return new Map<String, Object>{
'success' => true,
'data' => new Map<String, Object>{ 'quotes' => quoteMaps },
'errors' => new List<Map<String, Object>>()
};
} catch (Exception e) {
return new Map<String, Object>{
'success' => false,
'data' => new Map<String, Object>{ 'quotes' => new List<Map<String, Object>>() },
'errors' => new List<Map<String, Object>>{
new Map<String, Object>{
'code' => 'QUERY_ERROR',
'message' => e.getMessage()
}
}
};
}
}
}
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: 323k | 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: 323k | 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: 323k | Updated | Claude CodeCodex | Verified | Install |