In this article (6 sections)
The problem
Step: generating the quote document. A quote had to come out as a branded document, with the customer, the lines and the totals, in the company’s existing Word template. The pricing engine already read that quote through a context definition: the description of the quote data the pricing procedure uses.
The usual approach builds an extraction layer to feed the Word template. That is a second description of the same data, and it has to be maintained alongside every change to the quote model.
The solution
Two descriptions of the same quote drift apart. A field added for pricing goes into the context definition, because pricing would break without it. Nothing forces anyone to add it to the extract, so the document falls behind the quote, and nobody notices until a customer reads a document that doesn’t match the price.
Pointing the document template at the same context definition the pricing procedure uses removes the second description. The data contract already exists and is already maintained, because pricing depends on it. Tokens in the template are then simply the names of context attributes.
Setting it up
- Bind the template to the context instead of a custom extract.
- Name every token exactly like its attribute. Custom attributes keep their
__csuffix in the token. - Tag every attribute you plan to use. An attribute can only be used as a token if it carries a context tag. Inherited attributes are already tagged and work right away. Custom ones must be mapped, tagged and republished. That is why “only the inherited ones work” is the first symptom you will see.
- Format dates and resolve names before the template sees them. A raw date shows as an ISO timestamp, and the context exposes an account reference rather than the account name.
The choice and its cost
Using the pricing context has a price: document changes touch a definition pricing also depends on. Adding attributes is safe. Anything else deserves a sandbox first.
In exchange there is no second data layer to maintain, and the document and the price can’t disagree about what the quote contains.
An external document service makes sense at high volume, or when the document needs content Salesforce should not store. For a quote document, it adds a dependency for no gain.
In practice
- Bind the template to the pricing context definition, not to a custom extract.
- Tag and republish every custom attribute before using it as a token.
- Check which total is net before putting it on the document.
- Upload new versions of the template file, never a replacement file.