Create a transaction from an opportunity
- Step 1: Create a POST request
- Step 2: Configure authorization
- Step 3: Configure headers
- Step 4: Add JSON payload
- Step 5: Send your request
- Example request
- Example response
To try out the steps in this section, install Postman and open the Postman collection we have prepared for you. In the collection, open the Create a transaction from an opportunity request and replace variables with actual values.
Download Postman Open Postman Collection
Step 1: Create a POST request
Configure your application to send the following request:
POST https://{your_Salesforce_domain}/services/data/v44.0/actions/custom/apex/s2cor__Sage_INV_Create_Transaction
where
- {your_Salesforce_domain} is your Salesforce sandbox or production domain, for example,
my-domain-1234.cs89.my.salesforce.com
. - v44.0 is the Force.com REST API version you want to use.
- s2cor__Sage_INV_Create_Transaction is a method exposed by Financials that allows you to create a Transaction record for a specified Opportunity record.
Step 2: Configure authorization
Make sure your request uses OAuth 2.0. Authorization data must be included in the request URL.
Step 3: Configure headers
Configure the request headers to include the following key-value pairs:
Key | Value |
---|---|
Authorization | Bearer {access_token} Example: Bearer 00D0N000000h6Yq!AR0AQObORnk9lCldrMydk1Y3cuyqpscqcU.T1xvoM1uWkWrr8MLu2ehJLKp7Mz3Qeu.eQGI13qlH_HfGEEMxV_J8FdI1TwdR |
Content-Type | application/json |
Step 4: Add JSON payload
Add the following JSON payload to the request body:
{
"inputs" : [ {
"sourceId" : "{ salesforce_record_id }",
"targetTransactionType" : "{ target_transaction_type }"
} ]
}
In this JSON, replace the following placeholders with actual values:
- { salesforce_record_id } is the
Id
attribute value of the source Opportunity record from which you want to create a Transaction record. For example,0060N00000SjOeSQAV
. - { target_transaction_type } is the
s2cor__UID__c
(recommended) orName
attribute value of the target Transaction Type record. For example,SalesInvoice_TD_GB
. Financials uses the Transaction Type record you specify to create a new Transaction record from the opportunity.
TIP: Values of the s2cor__UID__c
attribute can be autogenerated or created manually. We recommend that you manually create descriptive, self-explanatory values. Ensure that each s2cor__UID__c
value you create is unique across your Salesforce org.
Step 5: Send your request
As a result, Financials creates a new draft Transaction record whose post status is Unposted and returns the record ID in the response.
NOTE: You can use a tool called Object Maps to map the fields of an Opportunity record to the corresponding fields of a Transaction record. For more information, see the article Object Maps - Financials posted on the Sage Customer Community.
Example request
POST https://my-domain.01.salesforce.com/services/data/v44.0/actions/custom/apex/s2cor__Sage_INV_Create_Transaction
{
"inputs" : [ {
"sourceId" : "0060E000008egNmQAI",
"targetTransactionType" : "ContractProposal_TD_IE"
} ]
}
Example response
[
{
"actionName": "s2cor__Sage_INV_Create_Transaction",
"errors": null,
"isSuccess": true,
"outputValues": {
"output": "a1v0E000000VtfWQAS"
}
}
]
where output
contains the Id
of the created Transaction record (a1v0E000000VtfWQAS
).