How to control the sort order of invoice line items?
Basically, the sort order of invoice line items is always controlled via the
In addition, there are other options that have an effect on the invoice line item listing:
- Aggregating and distributing invoice line items using the
- Controlling the display of multiple invoice line items produced from one transactional subscription item using the
- Grouping invoice line items using a category defined on the template
Note, however, that these options merely "overlap" the sequence but do not completely change it.
With respect to the sequence, there are various input factors that can determine this value, depending on the way you create invoices.
If you bill subscriptions, the sequence of the subscription items defines the sequence of the resulting invoice line items.
When creating subscriptions and their items manually, JustOn sets a
Sequencevalue as you add an item. If necessary, you can later edit the subscription items and modify the
Sequencevalue as required.
When automatically generating subscriptions, JustOn sorts the items alphabetically by their source object's Salesforce ID, assigning a corresponding
Sequencevalue. If necessary, you can later edit the subscription items and modify the
Sequencevalue as required.
Using the ON field mechanism, you can propagate customized sequence numbers to your subscription items or invoice line items.
The actual way to implement this functionality in your org varies depending on your business requirements.
In broad outline, this involves the following major steps:
(1) Define the custom number field
ON_Sequence on your source object.
(2) Depending on your requirements, you can have this field set manually by a user, or automatically via a formula. The formula may, for example, evaluate categorization data (product family, product code, order product number, etc.) to calculate a sequence number that reflects the intended sort order - if, for example, you want products of the category "A" to be placed on top of the list, your formula should produce a sequence number starting with
(3) When generating the subscriptions or invoices, JustOn copies the value calculated in the
ON_Sequence field of the source object to the subscription item or invoice line item, respectively.
Example sequence formula
The following formula illustrates the sequence number generation. It evaluates a condition (order no. starts with
SL). If that is true, it returns a sequence number made of a custom auto-number value prepended with
1, if not, prepended with
IF ( BEGINS( ON_OrderNo__c , "SL"), VALUE (LPAD ( ON_OpportunityProductNo__c , 6 , '1' )), VALUE (LPAD ( ON_OpportunityProductNo__c , 6 , '9' )) )