Источник:
https://erconsult.eu/blog/electronic...join-in-pairs/
==============
<div data-elementor-type="wp-post" data-elementor-id="6683" class="elementor elementor-6683" data-elementor-settings="[]"> <div class="elementor-section-wrap"> <div class="elementor-container elementor-column-gap-default"> <div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b53689d" data-id="b53689d" data-element_type="column"> <div class="elementor-widget-wrap elementor-element-populated">
D365 Electronic Reporting: JOIN records in pairs
<div class="elementor-element elementor-element-65ba7c0 elementor-widget elementor-widget-text-editor" data-id="65ba7c0" data-element_type="widget" data-widget_type="text-editor.default"> <div class="elementor-widget-container"> Recently, I came across a really challenging requirement in Electronic Reporting / Configurable Business Documents in Dynamics: in an additional section in the Delivery note, print a flat table where every pair of consecutive records becomes one line:
NoNot like thisBut like thisNo1Left laceLeft lace – Right lace12Right laceLeft shoe – Right shoe23Left shoe4Right shoeThis required a set of sophisticated techniques I am thrilled to share. The idea is to split into odd and even records and build something like
SELECT *, ROW_NUMBER as Rn1 FROM Records JOIN *, ROW_NUMBER as Rn1 from Records ON Rn2= Rn1+1
<ol>Enumerate: make a so called
Calculated field at the ER configuration’s root level with a record list and a row
Number inside:
ENUMERATE(ALLITEMS(MyRecords))

Add another Calculated field at the row level to check if the current record has an odd or an even row number: LEN(REPLACE("13579",RIGHT(NUMBERFORMAT(@.Number,"#"),1),"",false))