Apex Actions
This guide documents the Apex Actions (Invocable Methods) provided by the Suger Salesforce App. These actions can be used in Salesforce Flows, Process Builder, and other automation tools to integrate co-sell workflows.
Overview
Suger provides four Apex Actions for co-sell automation:
| Action | Description | Supported Partners |
|---|---|---|
| Check If Opportunity Shared | Check if an opportunity has been shared as a referral | AWS, Azure, GCP |
| Co-Sell | Share an opportunity with a cloud partner | AWS, Azure, GCP |
| Process Inbound Co-Sell Referral | Accept or decline an inbound referral | Azure only |
| Update Referral-Opportunity Linkage | Link a referral to an opportunity | AWS, Azure, GCP |
Check If Opportunity Shared
API Name: CosellCheckSharedOppApexAction
Label: Check If Opportunity Shared
Description: Check if an opportunity has already been shared as a co-sell referral with a specific partner or any partner.
Supported Partners
AWS, Azure, GCP, or ANY (checks all partners)
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| Opportunity ID | Id | Yes | Salesforce Opportunity ID to check |
| Partner | String | No | Partner to check: AWS, AZURE, GCP, or ANY. Defaults to ANY if not specified |
Outputs
| Parameter | Type | Description |
|---|---|---|
| Success | Boolean | Whether the operation completed successfully |
| Has Been Shared | Boolean | Whether the opportunity has been shared with the specified partner |
| Message | String | Descriptive message about the result |
Example Use Cases
- Prevent duplicate referral submissions by checking if an opportunity was already shared
- Conditionally show/hide co-sell buttons based on sharing status
- Validate before triggering co-sell automation
Co-Sell (Share Opportunity)
API Name: CosellShareReferralAsyncApexAction
Label: Co-Sell
Description: Share an opportunity with a co-sell partner. This action creates a new referral in the cloud partner's system and backfills the referral record to Salesforce.
Supported Partners
AWS, Azure, GCP
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| Partner | String | Yes | Cloud partner: AWS, AZURE, or GCP |
| Opportunity ID | Id | Yes | Salesforce Opportunity ID to share |
Outputs
| Parameter | Type | Description |
|---|---|---|
| Success | Boolean | Whether the referral was created successfully |
| Message | String | Error message if the operation failed |
| Referral ID | Id | Salesforce Referral record ID (if successful) |
| External Referral ID | String | Suger Referral ID (returned even on partial failure) |
Behavior
- Validates user has write permission for the specified partner
- Generates a preview of the referral data from the opportunity
- Creates the referral in the cloud partner's system via Suger
- Polls for workflow completion (up to ~12 seconds)
- Backfills the referral record to Salesforce
This action performs HTTP callouts and may take several seconds to complete. The external referral ID is returned even if later steps fail, allowing for manual recovery.
Process Inbound Co-Sell Referral
API Name: CosellProcessInboundReferralApexAction
Label: Process Inbound Co-Sell Referral
Description: Accept or decline an inbound co-sell referral from a cloud partner.
Supported Partners
Azure only - AWS and GCP inbound referrals must be processed through their respective partner portals or the Suger UI.
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| Partner | String | Yes | Must be AZURE |
| Referral ID | String | Yes | Suger Referral ID (not the Salesforce record ID) |
| Decision | String | Yes | ACCEPT or DECLINE |
| Reason | String | No | Reason for declining (only applicable when declining) |
Outputs
| Parameter | Type | Description |
|---|---|---|
| Success | Boolean | Whether the operation completed successfully |
| Message | String | Error message if the operation failed |
Behavior
When accepting:
- Updates the referral status to
Activewith substatusAccepted - Invokes the pre-acceptance webhook (if configured)
When declining:
- Updates the referral status to
Closedwith substatusDeclined - Sets the status reason with the provided decline reason
This action only supports Azure referrals. Attempting to use it with AWS or GCP will return an error.
Update Referral-Opportunity Linkage
API Name: CosellUpdateReferralLinkageApexAction
Label: Update Referral-Opportunity Linkage
Description: Link or update the linkage between a referral and a Salesforce opportunity. This is useful for manually associating referrals with opportunities or updating the linkage after the initial creation.
Supported Partners
AWS, Azure, GCP
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| Partner | String | Yes | Cloud partner: AWS, AZURE, or GCP |
| Opportunity ID | Id | Yes | Salesforce Opportunity ID to link |
| Referral ID | String | Yes | Suger Referral ID to update |
Outputs
| Parameter | Type | Description |
|---|---|---|
| Success | Boolean | Whether the linkage was updated successfully |
| Message | String | Error message if the operation failed |
Behavior
- Validates user has write permission for the specified partner
- Fetches the referral from Suger
- Updates the
salesforceOpportunityIdfield on the referral - For Azure referrals, also updates the
externalReferenceIdin the Microsoft referral set
Permission Requirements
All Apex Actions require appropriate co-sell permissions:
| Action | Required Permission |
|---|---|
| Check If Opportunity Shared | None (read-only check) |
| Co-Sell | Write_AWS_Referral, Write_Azure_Referral, or Write_GCP_Referral (based on partner) |
| Process Inbound Referral | Write_Azure_Referral |
| Update Referral Linkage | Write_AWS_Referral, Write_Azure_Referral, or Write_GCP_Referral (based on partner) |
Users with the Create_Referral permission have write access to all partners.
Using Apex Actions in Flows
To use these actions in a Salesforce Flow:
- Add an Action element to your flow
- Search for the action by its label (e.g., "Co-Sell" or "Check If Opportunity Shared")
- Configure the input parameters
- Store the output values in flow variables for decision logic or display
Example Flow: Auto-Share Opportunity
1. [Trigger] Opportunity Stage = "Closed Won"
2. [Action] Check If Opportunity Shared (Partner: AWS)
3. [Decision] Has Been Shared = false?
- Yes → [Action] Co-Sell (Partner: AWS)
- No → [End]
4. [Decision] Success = true?
- Yes → [Update Record] Set custom field "AWS Referral Created" = true
- No → [Create Task] "Review failed AWS co-sell submission"
Error Handling
All actions return a Success boolean and Message string. Common error scenarios:
| Error | Cause | Resolution |
|---|---|---|
| "unsupported partner: X" | Invalid partner value | Use AWS, AZURE, or GCP (case-sensitive) |
| "only Azure is supported" | Using Process Inbound with non-Azure partner | Use Azure partner or process through partner portal |
| Permission denied | User lacks required custom permission | Assign appropriate permission set |
| "Referral not found" | Invalid referral ID | Verify the Suger referral ID is correct |
| "No response from Suger" | API connectivity issue | Check Suger integration status |
Always check the Success output before proceeding with downstream logic. Store the Message output for debugging failed operations.