Portal Community

opportunity/close

Close an Opportunity as Won or Lost. A semantic convenience that sets StageName, IsClosed, and IsWon in a single operation.

How It Works: Closing as Won sets StageName to Closed Won and IsWon to true. Closing as Lost sets StageName to Closed Lost and IsWon to false. Under the hood, this performs a standard field update via the Salesforce REST API.

When to Use

Configuration

Connection

FieldTypeRequiredDescription
InstanceUrlstringrequiredSalesforce org URL.
AccessTokenstringrequiredValid OAuth2 access token.

Operation Fields

FieldTypeRequiredDescription
OpportunityIdstringrequired18-character Salesforce Opportunity ID.
IsClosedboolrequiredSet to true to close the opportunity.
IsWonboolrequiredSet to true for Closed Won, false for Closed Lost.

Sample Configuration

{
  "Resource": "opportunity",
  "Operation": "close",
  "InstanceUrl": "https://myorg.my.salesforce.com",
  "AccessToken": "{{credentials.salesforce.accessToken}}",
  "OpportunityId": "{{trigger.opportunityId}}",
  "IsClosed": true,
  "IsWon": true
}

Validation Errors

Error CodeCondition
CFG_MISSING_INSTANCEInstanceUrl is missing.
CFG_MISSING_TOKENAccessToken is missing.
VAL_MISSING_FIELDOpportunityId, IsClosed, or IsWon is missing.
UNEXPECTED_ERRORUnexpected exception.

Output

Success Port

FieldTypeDescription
statusstringAlways closed.
resourcestringAlways opportunity.
operationstringAlways close.

Error Port

FieldTypeDescription
errorCodestringMachine-readable error code.
messagestringError description.

Sample Output

{ "status": "closed", "resource": "opportunity", "operation": "close" }

Expression Reference

ExpressionDescription
{{nodes.CloseOpportunity.status}}Close operation result.
{{nodes.CloseOpportunity.errorCode}}Error code from error port.

Node Policies & GuardRails

PolicyDetail
Already closedClosing an already-closed opportunity may trigger validation rule errors. Use opportunity/get to check IsClosed before calling this operation.
Stage name requirementYour org must have Closed Won and Closed Lost defined as pipeline stages. Verify in Opportunity Stage settings.
Downstream triggersClosing an opportunity may fire Salesforce workflow rules and Process Builder automations. Test in sandbox.
Error port wiringAlways wire the error port.
Sandbox testingTest in sandbox before production. Especially important given downstream automation triggers.

Examples

Close as Won on Contract Signature

{
  "OpportunityId": "{{trigger.opportunityId}}",
  "IsClosed": true,
  "IsWon": true
}
// Downstream: trigger onboarding workflow, send congratulations Slack message

Mark as Lost When Competitor Wins

{
  "OpportunityId": "{{trigger.opportunityId}}",
  "IsClosed": true,
  "IsWon": false
}

Batch Close Expired Opportunities

// GetAll: Query = "IsClosed = false AND CloseDate < TODAY"
// Loop: opportunity/close each
{
  "OpportunityId": "{{loop.current.Id}}",
  "IsClosed": true,
  "IsWon": false
}