In this article (6 sections)
The problem
Step: posting invoice lines to the general ledger. Finance wanted each invoice line posted to the right ledger account based on two criteria, product family and tax zone. With several product families plus the tax dimension, that meant dozens of assignment rules, maintained by an accountant rather than an admin.
Salesforce has ledger assignment rules for exactly this. The information they needed was missing: the invoice carried neither criterion. And a rule written against the wrong field can’t be fixed afterwards, which the project found out the hard way.
The solution
A ledger assignment rule can only route on what the invoice carries, and the invoice carries surprisingly little: no country field, an empty billing profile reference, and a TaxCode on the line that stays empty even after posting. The product family lives on the product and the tax zone on the account. Neither is copied onto the invoice, so a rule has nothing to match on.
The fix is to bring both dimensions down onto the invoice line with formula fields: the tax zone from the account, the accounting family from the product. Rules then match on family × zone, and each piece of data keeps a single source.
The order matters more than usual because of how the rules are stored. Their criteria can be added but never edited or deleted (details below), so a rule written before the data is on the line stays in the org for good.
Setting it up
- Add the two dimensions where they are maintained: the zone on the account, the family on the product.
- Bring them down to the invoice line as formula fields.
- Deactivate the rule before adding any criterion.
- Prove every rule with a real posted invoice. Reading the configuration proves nothing, because it accepts anything.
Two more things send a criterion to the wrong field while setting this up:
Invoice.BillingAccountIdpoints at Account, not at theBillingAccountobject, despite its name.- A newly deployed formula or custom field is invisible to SOQL and Apex until field-level security is granted. SOQL answers “No such column”, which looks exactly like a failed deployment.
The choice and its cost
Formula fields keep one source per piece of data: the zone stays on the account, the family on the product. The consequence is that routing follows the current value of the source, not the value at invoice time. For a tax zone that is usually what finance wants. For anything that must be frozen at posting, a text field written once is safer.
In practice
- Bring routing data down onto the invoice line before writing a single rule.
- Write each criterion once, carefully: it can never be edited or deleted.
- Deactivate the rule before adding a criterion.
- Post one real invoice per rule and check the ledger account it lands in.