Suger

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:

ActionDescriptionSupported Partners
Check If Opportunity SharedCheck if an opportunity has been shared as a referralAWS, Azure, GCP
Co-SellShare 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 completionAWS, Azure, GCP
Process Inbound Co-Sell ReferralAccept or decline an inbound referral (Azure referral or AWS engagement invitation)Azure, AWS
Update Referral-Opportunity LinkageLink a referral to an opportunityAWS, Azure, GCP
Update AWS ReferralUpdate business fields on an AWS co-sell referralAWS 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

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 IDIdNoSalesforce Opportunity ID to share. Required unless Referral Payload (JSON) is provided
Referral Payload (JSON)StringNoA 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

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. Builds the referral payload — from the supplied Referral Payload (JSON) if provided, otherwise from the opportunity via field mapping
  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

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

ParameterTypeRequiredDescription
PartnerStringYesCloud partner: AWS, AZURE, or GCP
Opportunity IDIdNoSalesforce Opportunity ID to share. Required unless Referral Payload (JSON) is provided
Referral Payload (JSON)StringNoA 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

ParameterTypeDescription
SuccessBooleanWhether the create workflow started successfully
MessageStringError message if the operation failed
Referral IDStringSuger Referral ID — the external referral ID (no Salesforce record is created)
PartnerStringThe partner the referral was shared with

Behavior

  1. Validates user has write permission for the specified partner
  2. Builds the referral payload — from the supplied Referral Payload (JSON) if provided, otherwise from the opportunity via field mapping
  3. 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

ParameterTypeRequiredDescription
PartnerStringYesAZURE or AWS
Referral IDStringYesSuger Referral ID (not the Salesforce record ID)
DecisionStringYesACCEPT or DECLINE
ReasonStringNoReason 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

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

Behavior

Azure — when accepting:

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

Azure — when declining:

  • Updates the referral status to Closed with substatus Declined
  • 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

ParameterTypeRequiredDescription
PartnerStringYesPartner: AWS, AZURE, GCP, or SUGER
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

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

ParameterTypeRequiredDescription
Referral IDStringYesSuger Referral ID to update
APN ProgramsStringNoSemicolon-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 StepStringNoNext step on the opportunity, up to 255 characters
Target Close DateDateNoMust be a future date (after today, UTC). AWS freezes this once the opportunity is Launched
Customer Business ProblemStringNoThe customer’s situation and the problem they need solved, 20 to 2,000 characters
Additional CommentsStringNoFree-text notes on the opportunity, up to 255 characters

Outputs

ParameterTypeDescription
SuccessBooleanWhether the referral was updated
MessageStringThe fields updated on success, or the reason it was refused
APN ProgramsStringThe full program list on the referral after the update, semicolon-separated
Referral StatusStringThe 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

  1. 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
  2. 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
  3. Fetches the referral from Suger
  4. Refuses a referral that belongs to another partner — the caller passes only a referral ID, so the referral’s own partner decides
  5. Refuses the update unless AWS has the opportunity at Approved or Action Required; AWS accepts changes in no other review status
  6. Refuses the update when the opportunity is Launched or Closed Lost, because AWS does not accept changes after close
  7. Refuses Model Provider PARC unless 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
  8. 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:

ActionRequired Permission
Check If Opportunity SharedNone (read-only check)
Co-SellWrite_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 ReferralWrite_Azure_Referral or Write_AWS_Referral (based on partner)
Update Referral LinkageWrite_AWS_Referral, Write_Azure_Referral, Write_GCP_Referral, or Write_Suger_Referral (based on partner)
Update Referral FieldsWrite_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:

  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 AWS and Azure are supported”Using Process Inbound with a partner other than AZURE or AWSUse 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 invitationOnly 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 expiredNothing to do — check the referral’s current state in Suger
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
“No fields supplied. Set at least one of: …”Update Referral Fields called with every field emptySet 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 picklistUse 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 truncateFix the value; nothing was sent
“Opportunity is Launched. AWS does not accept updates after close…”Referral is Launched or Closed LostNo update is possible after close

Spotted something wrong or out of date on this page? Tell us and we'll correct it.