{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":38012,"path":"order-management/transaction-manager-integration-get.md","title":"ServiceNow Quote Experience Integration - GET","bundle":null,"doc_type":null,"release":"australia","body":"\n# ServiceNow Quote Experience Integration - GET\n\nLearn how to access data from a third-party application such as Salesforce by using the GET integration.\n\nThis article describes how to retrieve the Salesforce opportunity ID, together with transaction details including the account name, opportunity name, shipping address, and billing address, and write them into CPQ transaction fields. This pattern is relevant to any integration that requires CPQ to request data from a third party.\n\n## Goal: End-user \\(buyside\\) flow\n\nWe begin by opening a ServiceNow Quote Experience transaction in Salesforce. Then, by clicking **Get SF Data** in the buyside UI, we trigger the Get SF Data event. This event initiates several integrations that connect to Salesforce, extracting the relevant transaction data \\(opportunity ID, opportunity name, shipping address, billing address, account ID, and account name\\) and populating the corresponding fields in the buyside UI.\n\nIn the buyside transaction UI, click **Get SF Data**.\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-1.png\"\\] Alt text: Get SF Data\n\nNotice that the details are all populated.\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-2.png\"\\] Alt text: Transaction stages\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-3.png\"\\] Alt text: Get SF Data\n\nThe rest of this article lists the steps in CPQ to create the integrations that get the data from Salesforce.\n\n## Administration setup: Prerequisites\n\nThis guide assumes a CPQ environment with ServiceNow Quote Experience features enabled, as well as installation of the CPQ ServiceNow Quote Experience Integration Extension on a corresponding Salesforce environment. To view the installation instructions, see [Installing the Salesforce ServiceNow Quote Experience Integration Package extension](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/order-management/installing-the-salesforce-transaction-manager-integration-package-extension.md).\n\n## CPQ: Add a connection\n\nA connection record contains the data required to initiate a ServiceNow Quote Experience Integration. This includes authentication details, host URL, path, and headers. To view a connection record, in CPQ Admin, go to **Utilities**, and then click **Connections**.\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-add-connection.png\"\\] Alt text: Add a Connection\n\nFor information about adding a connection, see the \"Creating a Connection\" section in [ServiceNow Quote Experience Integrations](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/order-management/transaction-manager-integrations.md). For the purposes of this article, we use a connection to a Salesforce environment.\n\n## CPQ: Add the integration\n\n1.  Open CPQ Admin and go to the Integrations section.\n2.  Click **Add Integration**. Create a new integration using any suitable name. In this example, we use the name \"Get Oppty Id\".\n\n    \\[Omitted image \"cpq-txn-mgr-integration-get-add-opp-1.png\"\\] Alt text: Add Integration\n\n    \\[Omitted image \"cpq-txn-mgr-integration-get-add-opp-2.png\"\\] Alt text: Add Integration\n\n    The integration details page shown above includes the following sections:\n\n    -   Integration settings\n    -   Request Transformation\n    -   Connection to Endpoint\n    -   Response Transformation\n    Details about these sections follow.\n\n\n-   Integration settings:\n\n    -   HTTP method: GET\n    -   Path: `/services/data/vXX.X/query/?q=SELECT+Name,+LGK__OpportunityId__c FROM+LGK__Transaction__c+WHERE+LGK__ID__c='{{txn.id}}'`\n\n        The GET request retrieves the **Name** and **LGK\\_\\_OpportunityId\\_\\_c** fields from the **LGK\\_\\_Transaction\\_\\_c** object in Salesforce, filtering by the transaction ID “txn.id” in the **LGK\\_\\_ID\\_\\_c** field.\n\n        In the path, `<vXX.X>` is the latest composite graph version. You can check for the latest version [here](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_graph.htm).\n\n    -   Line Item Details to Include: Selected Lines\n    -   Timeout: 2000 ms\n    \\[Omitted image \"cpq-txn-mgr-integration-get-add-opp-3.png\"\\] Alt text: Add Integration\n\n    Click **Next**.\n\n-   Request Transformation: Not required when we are building a GET Integration.\n-   Connection to Endpoint: For this example, we are querying **Salesforce**. If you are setting up an integration with another system, select the appropriate connection.\n\n    \\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-4.png\"\\] Alt text: Add Integration\n\n    Click **Next**.\n\n-   Response Transformation: See this sample response transformation template.\n\n    ```\n    {\n      \"fields\": [\n        {\n          \"variableName\": \"txn.custom.tXNNumber\",\n          \"value\": \"{{#each records}}{{Name}}{{/each}}\"\n        },\n        {\n          \"variableName\": \"txn.opportunity.id\",\n          \"value\": \"{{#each records}}{{LGK__OpportunityId__c}}{{/each}}\"\n        }\n      ]\n    }\n    ```\n\n\n## Integration: Retrieve opportunity details\n\nCreate another integration to get additional details through **txn.opportunity.id**.\n\nNow that we have the opportunity ID, the next step in the integration involves using it as a reference to retrieve additional details from the opportunity and to populate the relevant LGK transaction fields.\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-1.png\"\\] Alt text: Admin transaction\n\n-   Integration settings:\n\n    -   HTTP method: GET\n    -   Path: `GET /services/data/vXX.X/query?q=SELECT Id,Name,Owner.Username,AccountId,Account.Name,Account.BillingAddress,Account.ShippingAddress FROM Opportunity WHERE Id='{{txn.opportunity.id}}'`\n\n        This query retrieves fields from an Opportunity record in Salesforce, based on the unique ID of the opportunity. It also retrieves related account details, such as the account's name, billing address, and shipping address. The query returns data for a specific opportunity identified by **\\{\\{txn.opportunity.id\\}\\}**.\n\n        To get the field details from Salesforce, click **Setup** &gt; **Object Manager** &gt; **Opportunity** &gt; **Fields &amp; Relationships**.\n\n        \\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-2.png\"\\] Alt text: Add Integration\n\n    -   Line Item Details to Include: Selected Lines\n    -   Timeout: 2000 ms\n\n        \\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-3.png\"\\] Alt text: Add Integration\n\n    Click **Next**.\n\n-   Request Transformation: not required when building a GET integration.\n-   Connection to Endpoint:\n\n    Select **Connection to Endpoint**. For this example, we are querying Salesforce. If you are setting up an integration with another system, select the appropriate connection.\n\n    \\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-4.png\"\\] Alt text: Add Integration\n\n    Click **Next**.\n\n-   Response Transformation: The following JSON snippet defines how to populate variables defined in additional path by iterating over a collection of `records`.\n\n    For **txn.custom.opportunity**, it extracts the **Name** field from each record, while for **txn.custom.billToAddress**, it extracts and concatenates the **Account.BillingAddress.street,Account.BillingAddress.city,Account.BillingAddress.state,Account.BillingAddress.postalCode** field. The Handlebars **\\{\\{\\#each\\}\\}** loop is used to process each record, and the resulting values depend on the system's handling, either as concatenated strings or arrays of values.\n\n    ```\n    {\n      \"fields\": [\n        {\n          \"variableName\": \"txn.custom.opportunity\",\n          \"value\": \"{{#each records}}{{Name}}{{/each}}\"\n        },\n        {\n          \"variableName\": \"txn.account.id\",\n          \"value\": \"{{#each records}}{{AccountId}}{{/each}}\"\n        },\n        {\n          \"variableName\": \"txn.custom.accountName\",\n          \"value\": \"{{#each records}}{{Account.Name}}{{/each}}\"\n        },\n        {\n          \"variableName\": \"txn.custom.quoteNumber\",\n          \"value\": \"{{#each records}}{{QuoteNumber}}{{/each}}\"\n        },\n        {\n          \"variableName\": \"txn.custom.billToAddress\",\n          \"value\": \"{{records.[0].Account.BillingAddress.street}}{{records.[0].Account.BillingAddress.city}}{{records.[0].Account.BillingAddress.state}}{{records.[0].Account.BillingAddress.postalCode}}\"\n        },\n        {\n          \"variableName\": \"txn.custom.shipToAddress\",\n          \"value\": \"{{records.[0].Account.ShippingAddress.street}}{{records.[0].Account.ShippingAddress.city}}{{records.[0].Account.ShippingAddress.state}}{{records.[0].Account.ShippingAddress.postalCode}}\"\n        }\n      ]\n    }\n    ```\n\n\nTrigger the integration when the end user clicks a button. You can now click **Events** to create a new event or to select an existing one. In this case, we use the Get SF Data event \\(a button in the UI\\) to connect to the integrations we previously created.\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-5.png\"\\] Alt text: Admin transaction\n\nClick **Add New Action**.\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-6.png\"\\] Alt text: Add Integration\n\nClick **Integrations**.\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-7.png\"\\] Alt text: Add Integration\n\nSearch for and add the \"Get Oppty Id\" integration.\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-8.png\"\\] Alt text: Add Integration\n\nClick **Save**. Then, click **Add New Action** and add \"retrieveSFOptyData\".\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-9.png\"\\] Alt text: Add Integration\n\nClick the up and down arrows next to the action items to arrange them in the desired order. \\(Here, we are selecting \"Get Oppty Id\", followed by \"Retrieve SF Opty Data\", to fetch the opportunity ID and retrieve relevant data.\\)\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-10.png\"\\] Alt text: Add Integration\n\nClick **Save**, and deploy the changes.\n\nWe have discussed how integrations can be added with events. Integrations can also be configured at the stage level. To do so, navigate to **Stages** &gt; **Edit Settings** &gt; **Add New Action** &gt; **Integration**.\n\n\\[Omitted image \"cpq-txn-mgr-integration-get-retrieve-opp-11.png\"\\] Alt text: Add Integration\n\n## Troubleshooting\n\nWhen configuring integrations, it is crucial to ensure that the sequence of integrations is set up correctly to retrieve accurate details. The order of execution plays a significant role in maintaining data consistency and alignment.\n\nTo achieve this, follow these steps:\n\n1.  Fetch the opportunity ID: The opportunity ID serves as the key reference for linking related data. This step is essential because the transaction details you retrieve later are directly associated with a specific opportunity.\n2.  Fetch the transaction ID through opportunity details: Use the opportunity ID to fetch the transaction ID. Because each transaction is linked to a particular opportunity, this approach ensures that you accurately associate the correct transaction with its corresponding opportunity.\n\nBy following this order, you can maintain the integrity of the integration and ensure that the data flow remains seamless and reliable.\n\n**Related topics**  \n\n\n[ServiceNow Quote Experience Integration - POST](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/order-management/transaction-manager-integration-post.md)\n\n"}}