How can I influence Rebate Records order?


My issue is that Rebate Records are displayed in a different order than they were created. Let’s say I create records in this way: 1st, then 2nd, then 3rd. Then I use rebateRecords.getAll() and it returns 2nd, 3rd and then 1st.


The method rebateRecords.getAll() returns records (for the given line item) sorted by rank (field RebateRecord.FIELD_RANK) which you can set when creating the records. Rank is also used to determine the order in which the records should be calculated.

If it is just for viewing, you can also sort by ID or similarly in Groovy.

As for the creation order, RRs are created in the order in which your logic calls rebateRecords.add() method. If there is no RR for a line item, for the same Rebate Record set, with the same rebateRecordName, a new one is created, otherwise an existing one is updated.

Records have ever increasing IDs, in the order of creation, so the order is deterministic.

Found an issue in documentation? Write to us.