Skip to main content

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:

ActionDescriptionSupported Partners
Check If Opportunity SharedCheck if an opportunity has been shared as a referralAWS, Azure, GCP
Co-SellShare an opportunity with a cloud partnerAWS, Azure, GCP
Process Inbound Co-Sell ReferralAccept or decline an inbound referralAzure only
Update Referral-Opportunity LinkageLink a referral to an opportunityAWS, 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

ParameterTypeRequiredDescription
Opportunity IDIdYesSalesforce Opportunity ID to check
PartnerStringNoPartner to check: AWS, AZURE, GCP, or ANY. Defaults to ANY if not specified

Outputs

ParameterTypeDescription
SuccessBooleanWhether the operation completed successfully
Has Been SharedBooleanWhether the opportunity has been shared with the specified partner
MessageStringDescriptive 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

ParameterTypeRequiredDescription
PartnerStringYesCloud partner: AWS, AZURE, or GCP
Opportunity IDIdYesSalesforce Opportunity ID to share

Outputs

ParameterTypeDescription
SuccessBooleanWhether the referral was created successfully
MessageStringError message if the operation failed
Referral IDIdSalesforce Referral record ID (if successful)
External Referral IDStringSuger Referral ID (returned even on partial failure)

Behavior

  1. Validates user has write permission for the specified partner
  2. Generates a preview of the referral data from the opportunity
  3. Creates the referral in the cloud partner's system via Suger
  4. Polls for workflow completion (up to ~12 seconds)
  5. Backfills the referral record to Salesforce
note

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

ParameterTypeRequiredDescription
PartnerStringYesMust be AZURE
Referral IDStringYesSuger Referral ID (not the Salesforce record ID)
DecisionStringYesACCEPT or DECLINE
ReasonStringNoReason for declining (only applicable when declining)

Outputs

ParameterTypeDescription
SuccessBooleanWhether the operation completed successfully
MessageStringError message if the operation failed

Behavior

When accepting:

  • Updates the referral status to Active with substatus Accepted
  • Invokes the pre-acceptance webhook (if configured)

When declining:

  • Updates the referral status to Closed with substatus Declined
  • Sets the status reason with the provided decline reason
warning

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

ParameterTypeRequiredDescription
PartnerStringYesCloud partner: AWS, AZURE, or GCP
Opportunity IDIdYesSalesforce Opportunity ID to link
Referral IDStringYesSuger Referral ID to update

Outputs

ParameterTypeDescription
SuccessBooleanWhether the linkage was updated successfully
MessageStringError message if the operation failed

Behavior

  1. Validates user has write permission for the specified partner
  2. Fetches the referral from Suger
  3. Updates the salesforceOpportunityId field on the referral
  4. For Azure referrals, also updates the externalReferenceId in the Microsoft referral set

Permission Requirements

All Apex Actions require appropriate co-sell permissions:

ActionRequired Permission
Check If Opportunity SharedNone (read-only check)
Co-SellWrite_AWS_Referral, Write_Azure_Referral, or Write_GCP_Referral (based on partner)
Process Inbound ReferralWrite_Azure_Referral
Update Referral LinkageWrite_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:

  1. Add an Action element to your flow
  2. Search for the action by its label (e.g., "Co-Sell" or "Check If Opportunity Shared")
  3. Configure the input parameters
  4. 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:

ErrorCauseResolution
"unsupported partner: X"Invalid partner valueUse AWS, AZURE, or GCP (case-sensitive)
"only Azure is supported"Using Process Inbound with non-Azure partnerUse Azure partner or process through partner portal
Permission deniedUser lacks required custom permissionAssign appropriate permission set
"Referral not found"Invalid referral IDVerify the Suger referral ID is correct
"No response from Suger"API connectivity issueCheck Suger integration status
tip

Always check the Success output before proceeding with downstream logic. Store the Message output for debugging failed operations.