---
sourceDocument: Xanadu Customer Service Management
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/customer-service-management

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu Customer Service Management

ft:clusterId :

    - csm

bundleId :

    - csm

workflow :

    - Customer and Industry


---

# Using a related list to create the connection between the Customer Account and Salesforce Opportunities

# Using a related list to create the connection between the Customer Account and Salesforce
Opportunities {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

Use a related list to establish the connection between the Customer Account table
that holds the Salesforce Account Id and the Salesforce Opportunity remote table that holds
the same Salesforce Account Id.

In this example, create a relationship called Opportunities. Choose the Account table in
the Applies to table field and the remote opportunity table in the
Queries from table field. For more information, see [Create defined related
lists](https://www.servicenow.com/docs/access?context=t_CreateDefinedRelatedLists&version=xanadu&pubname=xanadu-platform-user-interface&ft:locale=en-US).

Add the following code in the Query with field:  

    (function refineQuery(current, parent) {

      var sf_account_id = new String(parent.u_salesforce_account_id);

      if (sf_account_id.length == 0)
        sf_account_id = "undefined";

      current.addQuery("u_sf_account_id", sf_account_id);

    })(current, parent);

This code checks for the presence of the Salesforce Account Id in the Account table and,
if it is missing in the record, sets it to `undefined`. The code also
includes a query for the Opportunity table column that holds the Salesforce Account Id
for the value of this Id from the Account table. This query is invoked when the user
opens the list of opportunities associated with the customer account. To see how it is
used in the remote table script, see [Selecting a spoke action and preparing the inputs](https://servicenow-prod.fluidtopics.net/BWxSltTMYZetcHjzDAHynw#csm-opportunity-table-script__section_select_spoke_actions).

