ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

Grouping Document Entries for multiple source lines

Open Rub19Luc21 opened this issue 6 years ago • 3 comments

In our solution a lot of document lines are grouped together and shown as one line. As a consequence we also need to show some related entities as a group.

On most places this is not a problem, but on the Document Line Tracking page it's a little harder. In this page the parameters are set to find one specific Source Record (SetDoc procedure) and when the page is opened then the related records are found for that specific Source Record. (OnOpenPage calls FindRecords)

The easiest way to solve this (for us at least) is to make the FindRecords function global (it's currently a local procedure). In that way we can build a loop for all the source document lines we want to include before opening the page and show all relevant related document entries on the Document Line Tracking page itself. In standard BC the FindRecords procedure can then still be called in the OnOpenPage trigger, but we will call the FindRecords procedure for all the source records that we want to include upfront.

For this solution to work we also need to prevent that the DeleteAll in the FindRecords procedure is executed. Maybe you can add an publisher event there with an IsHandled and only call the FindRecords function if the IsHandled is false.

And even though we don't directly need it, maybe it's a good idea to add a GetTempDocumentEntry(var TempDocumentEntry) and SetTempDocumentEntry(var TempDocumentEntry) procedure on the page, so that others can inject additional entries from outside the page.

An alternative approach would be to work with event publishers on all FindxxxLines procedures in the page. But that wouldn't solve all our problems, because the filters on the underlying page that opens the Document Line Tracking determines if we should or shouldn't group multiple source lines. (So for instance the filters on the Posted Purchase Invoice Subform page determines if we want to group or not). The problem is that we don't have access to these filters when the events are triggered... Therefore, we need the source record as a VAR in the page (only a var record will give us access to the filters) and in all these events as well. Maybe instead of the record as VAR, a RecordID can be used instead, because there can be many source records from which this page can be opened. (And I believe that also a RecordID will hold the filters for us.. (?)) But we would have to catch many events for this solution to work and that's why I prefer the first solution.

I hope you understand what we try to accomplish and what the issues are. Maybe you have a completely different approach and that's also fine of course. In any case feel free to contact me if you have any questions or need more details.

Kind regards, Ruben Schoester Solution Architect K3 Software Solutions

Rub19Luc21 avatar Jul 08 '20 16:07 Rub19Luc21

We have several options:

  1. We can warp call of Document Line Tracking by another procedure and let you overload this call using OnBefore handled event. This way you can design any alternative page and use it instead
  2. We can make FindRecords protected (to be used in page extension code) or even global. DeleteAll() can be moved out of this procedure and use once in OnOpenPage trigger just before call to FindRecords()
  3. We can also make TempDocumentEntry as protected var, then it will be directly available in page extension.

As this is old request, you probably already have working solution, let us know you current state for implementation.

AlexanderYakunin avatar Feb 03 '21 06:02 AlexanderYakunin

Thanks Alexander for your feedback.

We currently don't have a working solution. We try to ask for new events in advance, so we always do the analysis on available events prior to commencing the actual work. This work is pending till we get a solution that we can use.

To be honest I would like all 3 options to be available. But 2 and 3 are the ones we would probably use. It would indeed be really nice if the DeleteAll() is moved out of the procedure for option 2...

Kind regards, Ruben Schoester

Rub19Luc21 avatar Feb 04 '21 12:02 Rub19Luc21

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

JesperSchulz avatar Jun 10 '21 06:06 JesperSchulz