You are here:
Example: Generating a Proposal from a Quote by Using Context Service
Review the context definition structure, mapping, and JSON output that illustrate how Context Service can support proposal generation from a Quote record. It includes possible elements such as account details, billing information, product line items, and a company logo.
Required Editions
| Available in: Lightning Experience |
| Available in: Professional, Enterprise, Unlimited, and Developer Editions |
A sales rep needs to generate a customer proposal that includes billing address, quote summary, product line items, and a company logo. The rep wants the proposal document to dynamically reflect data from the Quote, QuoteLineItem, and related Product records.
Using Context Service, you can structure and map the necessary data through context definitions and mappings. These definitions and mappings are then referenced in a document template via context tokens. The result is a reusable and scalable solution for generating personalized proposal documents.
Context Definition Structure
This table shows example nodes, attributes, and their purpose when defining a context structure for contract documents.
| Node | Attribute | Purpose |
|---|---|---|
| Quote | AccountName | Show the customer account name |
| Quote | Name | Show the quote name or number |
| Quote | TotalPrice | Include total quote amount |
| Quote | QuoteId | Reference the unique quote ID |
| Quote | IMG_Logo_src | Show the company logo in the proposal |
| Quote | Country | Include billing country |
| Quote | PostalCode | Include billing postal code |
| Quote | State | Include billing state |
| Quote | City | Include billing city |
| Quote | Street | Include billing street address |
| Product | Product | Show the name of the quoted product |
| Product | Quantity | Display quantity per product |
| Product | UnitPrice | Show price per unit of product |
| Product | Amount | Show total amount per line item |
Context Mapping Example
This example reflects a mapping where the Quote node is mapped to a mix of direct fields and nested objects such as Account.Account.Name and IMGQ3Contract.JPEG__c. The QuoteLineItem node provides line-item-level data, and the Product node (referenced via QuoteLineItem.Product2) completes the data model.
| Context Attribute | Mapped Field in Salesforce | Token Format in Template |
|---|---|---|
| AccountName | Quote.Account.Account.Name | {{AccountName}} |
| Name | Quote.Name | {{Name}} |
| TotalPrice | Quote.TotalPrice | {{TotalPrice}} |
| QuoteId | Quote.Id | {{QuoteId}} |
| IMG_Logo_src | Quote.IMGQ3Contract.JPEG__c | {{IMG_Logo}} |
| Country | Quote.BillingCountry | {{Country}} |
| PostalCode | Quote.BillingPostalCode | {{PostalCode}} |
| State | Quote.BillingState | {{State}} |
| City | Quote.BillingCity | {{City}} |
| Street | Quote.BillingStreet | {{Street}} |
| Product | QuoteLineItem.Product2.Name | {{#Products}}{{Product}} {{/Products}} |
| Quantity | QuoteLineItem.Quantity | {{Quantity}} |
| UnitPrice | QuoteLineItem.UnitPrice | {{UnitPrice}} |
| Amount | QuoteLineItem.TotalPrice | {{Amount}} |
Sample JSON Output
{
"AccountName": "Acme Corporation",
"Name": "Q-2025-0421",
"TotalPrice": 18000,
"IMG_Logo: {
"src: 0697x00000XYZ123"
}
"Country": "USA",
"PostalCode": "10001",
"State": "NY",
"City": "New York",
"Street": "123 Main St",
"Products": [
{
"Product": "GenWatt Diesel 1000kW",
"Quantity": 2,
"UnitPrice": 8000,
"Amount": 16000
},
{
"Product": "Shipping",
"Quantity": 1,
"UnitPrice": 2000,
"Amount": 2000
}
]
}

