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 six 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 (waits for completion, backfills to Salesforce) | AWS, Azure, GCP |
| Co-Sell (Fire and Forget) | Share an opportunity without waiting for completion | AWS, Azure, GCP |
| Process Inbound Co-Sell Referral | Accept or decline an inbound referral (Azure referral or AWS engagement invitation) | Azure, AWS |
| Update Referral-Opportunity Linkage | Link a referral to an opportunity | AWS, Azure, GCP |
| Update AWS Referral | Update business fields on an AWS co-sell referral | AWS only |
How an action reaches the cloud partner
Every action runs the same three-system path: your Flow calls an Apex method in the managed package, the package calls Suger over HTTP, and Suger talks to the cloud partner. Where the actions differ is what happens after Suger accepts the request — whether the Flow waits for the partner, and whether a Salesforce record comes back in the same run.
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 | No | Salesforce Opportunity ID to share. Required unless Referral Payload (JSON) is provided |
| Referral Payload (JSON) | String | No | A complete referral payload as a JSON string (the same envelope used by the Create a Referral API). When provided, the field-mapping preview is skipped and this payload is submitted as-is |
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
- Builds the referral payload — from the supplied Referral Payload (JSON) if provided, otherwise from the opportunity via field mapping
- 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
Co-Sell (Fire and Forget)
API Name: CosellShareReferralAction
Label: Co-Sell (Fire and Forget)
Description: Share an opportunity with a co-sell partner without waiting for the create to finish. The action returns as soon as the create workflow starts — it does not poll for completion or backfill a Salesforce Referral__c record. Use it when you don’t need the result in the same Flow run.
Supported Partners
AWS, Azure, GCP
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| Partner | String | Yes | Cloud partner: AWS, AZURE, or GCP |
| Opportunity ID | Id | No | Salesforce Opportunity ID to share. Required unless Referral Payload (JSON) is provided |
| Referral Payload (JSON) | String | No | A complete referral payload as a JSON string (the same envelope used by the Create a Referral API). When provided, the field-mapping preview is skipped and this payload is submitted as-is |
Outputs
| Parameter | Type | Description |
|---|---|---|
| Success | Boolean | Whether the create workflow started successfully |
| Message | String | Error message if the operation failed |
| Referral ID | String | Suger Referral ID — the external referral ID (no Salesforce record is created) |
| Partner | String | The partner the referral was shared with |
Behavior
- Validates user has write permission for the specified partner
- Builds the referral payload — from the supplied Referral Payload (JSON) if provided, otherwise from the opportunity via field mapping
- Creates the referral in the cloud partner’s system via Suger and returns immediately
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 and AWS. For AWS the action processes a pending engagement invitation — the inbound form an AWS-originated referral arrives in. GCP inbound referrals must still be processed through the partner portal or the Suger UI.
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| Partner | String | Yes | AZURE or AWS |
| 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). For AWS this is passed to Partner Central, which requires a single line of at most 80 characters |
Outputs
| Parameter | Type | Description |
|---|---|---|
| Success | Boolean | Whether the operation completed successfully |
| Message | String | Error message if the operation failed |
Behavior
Azure — when accepting:
- Updates the referral status to
Activewith substatusAccepted - Invokes the pre-acceptance webhook (if configured)
Azure — when declining:
- Updates the referral status to
Closedwith substatusDeclined - Sets the status reason with the provided decline reason
AWS — when accepting:
- Accepts the engagement invitation in AWS Partner Central (ACE)
- Returns as soon as AWS takes the request. AWS creates the opportunity asynchronously, so the referral’s status and opportunity fields are filled in shortly afterwards by the inbound sync, not by this action
AWS — when declining:
- Rejects the engagement invitation in AWS Partner Central and sets the referral to
REJECTED - The decline reason is recorded on the Suger referral and sent on to AWS Partner Central. When no reason is given, AWS is sent
Other - If auto-delete is enabled for the org, the linked CRM records are removed
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, Suger (partner-to-partner co-sell)
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| Partner | String | Yes | Partner: AWS, AZURE, GCP, or SUGER |
| 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
Update AWS Referral Fields
API Name: CosellUpdateAwsReferralApexAction
Label: Update AWS Referral
Description: Update business fields on an existing AWS co-sell referral. Only the fields you supply are changed — leave a field out and it keeps its current value. A referral belonging to another partner is refused.
Supported Partners
AWS
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| Referral ID | String | Yes | Suger Referral ID to update |
| APN Programs | String | No | Semicolon-separated APN program names, e.g. Migration Acceleration Program;Well-Architected. Values must come from the AWS APN Program picklist. Model Provider PARC is accepted only on a referral AWS originated. Pass an empty value to remove every program |
| Next Step | String | No | Next step on the opportunity, up to 255 characters |
| Target Close Date | Date | No | Must be a future date (after today, UTC). AWS freezes this once the opportunity is Launched |
| Customer Business Problem | String | No | The customer’s situation and the problem they need solved, 20 to 2,000 characters |
| Additional Comments | String | No | Free-text notes on the opportunity, up to 255 characters |
Outputs
| Parameter | Type | Description |
|---|---|---|
| Success | Boolean | Whether the referral was updated |
| Message | String | The fields updated on success, or the reason it was refused |
| APN Programs | String | The full program list on the referral after the update, semicolon-separated |
| Referral Status | String | The referral status as it stood before this update, e.g. ACTIVE or ACTION_REQUIRED. Suger recomputes the status while saving, and the push to AWS can change it again after that — re-read the referral if a Flow must branch on the new value |
Behavior
- Validates that at least one field was supplied — every field is optional, but a request that sets none is refused rather than costing two callouts to write the referral back unchanged — and that the user has write permission for the partner
- Validates every supplied value before any callout and refuses the whole update if one fails: APN Programs must all be on the AWS APN Program picklist (an unrecognized value is rejected by AWS and blocks every later change to that referral), Target Close Date must be in the future, and the text fields must be within the lengths above. Suger would otherwise keep the old value or truncate silently, so it is caught here instead
- Fetches the referral from Suger
- Refuses a referral that belongs to another partner — the caller passes only a referral ID, so the referral’s own partner decides
- Refuses the update unless AWS has the opportunity at
ApprovedorAction Required; AWS accepts changes in no other review status - Refuses the update when the opportunity is
LaunchedorClosed Lost, because AWS does not accept changes after close - Refuses
Model Provider PARCunless AWS originated the referral — AWS rejects it on a partner-originated opportunity, and that rejection blocks every later change to the referral. It stays editable on an inbound referral - Applies only the supplied fields and sends the complete referral back to Suger, which pushes it to AWS asynchronously
APN Programs replace the full list rather than adding to it — AWS treats the field as a set. Send every program the referral should end up with.
Clearing APN Programs. Pass an empty value (in Flow, the Blank Value (Empty String) resource) to remove every program. This is the only field that can be cleared — the others are left untouched when blank, because AWS either requires them or enforces a minimum length. Note the current limitation: the empty set is stored in Suger, but it does not yet reach AWS, so the programs can reappear on the next inbound sync. Clearing at AWS is tracked separately.
Each request in a Flow collection gets its own result, so one bad row does not stop the others.
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) |
| Co-Sell (Fire and Forget) | Write_AWS_Referral, Write_Azure_Referral, or Write_GCP_Referral (based on partner) |
| Process Inbound Referral | Write_Azure_Referral or Write_AWS_Referral (based on partner) |
| Update Referral Linkage | Write_AWS_Referral, Write_Azure_Referral, Write_GCP_Referral, or Write_Suger_Referral (based on partner) |
| Update Referral Fields | Write_AWS_Referral |
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 AWS and Azure are supported” | Using Process Inbound with a partner other than AZURE or AWS | Use AZURE or AWS, or process through the partner portal |
| “Engagement invitation not found” | Process Inbound on an AWS referral that is not an inbound engagement invitation | Only AWS-originated inbound referrals carry an invitation to accept |
| “Engagement invitation is not pending, current status: X” | The AWS invitation was already accepted, rejected or has expired | Nothing to do — check the referral’s current state in Suger |
| 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 |
| “No fields supplied. Set at least one of: …” | Update Referral Fields called with every field empty | Set at least one field; a blank string counts as empty |
| “Not a valid value for APN Programs: X” | A program name not on the AWS APN Program picklist | Use the picklist values exactly; the whole update is refused, nothing was sent |
| ”… must be a future date” / ”… must be at least/most N characters” | A value Suger would silently drop or truncate | Fix the value; nothing was sent |
| “Opportunity is Launched. AWS does not accept updates after close…” | Referral is Launched or Closed Lost | No update is possible after close |
Spotted something wrong or out of date on this page? Tell us and we'll correct it.