---
sourceDocument: Australia Customer Service Management
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/pt-BR/customer-service-management

 Release :

    - australia

ft:locale :

    - pt-BR

ft:publication_title :

    - Australia Customer Service Management

ft:clusterId :

    - csm

bundleId :

    - csm

workflow :

    - Customer and Industry


---

# Get Opportunities for Account Id custom action

# Get Opportunities for Account Id custom action {#ariaid-title1}

* Versão de lançamento: Australia
* 
* Atualizado 12 de mar. de 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 min. de leitura

The Get Opportunities for Account Id action retrieves
opportunity records for the specific Salesforce account. This action is invoked when the agent
views a Salesforce opportunity available for the customer account based on the Salesforce
account associated with it.
This action is similar to the Get All Opportunities action.

## Action inputs {#csm-account-opportunities-action__section_cz2_m2z_53b}

In addition to the maximum number of records to be returned by the query, this action also
takes a Salesforce Account Id as input to be used as a query parameter. The value of this
parameter is provided by the relationship that links the customer account and the Salesforce
opportunity through the associated Salesforce Account Id. For more information, see [Create defined related
lists](https://servicenow-prod.fluidtopics.net/j8KeCAjjg1~IKrSnrP9~Zw "The Get Opportunities for Account Id action retrieves opportunity records for the specific Salesforce account. This action is invoked when the agent views a Salesforce opportunity available for the customer account based on the Salesforce account associated with it.").

The specific relationship needed for the reference example is also described in the [Using a related list to create the connection between the Customer Account and Salesforce
Opportunities](https://servicenow-prod.fluidtopics.net/ce5M~351JeTKW~m3pV7ejA "Use a related list to link the Customer Account table with Salesforce Account Id, and the Salesforce Opportunity remote table with the same Account Id.") topic.

The Salesforce Account Id action input parameter has no default value.


Action Outline with Inputs: Pre Processing script, REST step, Post Processing script. Action Input showing Label, Name, Type, and a toggle for Mandatory.

## Pre-processing step {#csm-account-opportunities-action__section_hrw_m2z_53b}

The pre-processing script step takes the action input as its own.

The Pre-Processing step script creates a SELECT query similar to the one created for the Get All Opportunities action with the addition of the check against the Salesforce Account Id.  

    (function execute(inputs, outputs) {
      
      outputs.query = "query/?q=SELECT+Name,Id,AccountId,CloseDate,Amount," +
                      "StageName,Probability,Type+FROM+Opportunity"         +
                      
                      "+WHERE+AccountId='" + inputs.salesforce_account_id + "

                      "+LIMIT+" + inputs.max_number_of_opportunity_records; 
      
    })(inputs, outputs);

The pre-processing output is a query, similar to the Get All Opportunities action.

## REST step, post-processing step, and action outputs {#csm-account-opportunities-action__section_j3b_n2z_53b}

These steps and outputs are the same as for the Get All Opportunities action.

