How to select more than 1 record on LookUp form?

How to Select More Than One Record On LookUp Form

I’ve seen quite a few modifications for Dynamics NAV, where users would select a few records on the list form and then would do something with them (for example, you could print selected invoices to PDF files, you could add selected items to the sales order , etc. I guess, only developer’s imagination is end-user’s limit in functionality). And from end-user perspective this is really a treat – instead of adding twenty different items on the sales order separately, you could do that in one go.

As it is weekend again (and the book I have started reading last week, today is somewhere in India), I decided to play around a little bit. How hard (or easy) can it be?  After playing around for a few minutes I came up with:

// NAVISIONARY 22/11/2009 >>

FormMyRecordList.SETTABLEVIEW(MyRecord);
FormMyRecordList.LOOKUPMODE(TRUE);
IF FormMyRecordList.RUNMODAL = ACTION::LookupOK THEN BEGIN
   SelectedRecord := MyRecord;
   FormMyRecordList.SetSelection(SelectedRecord);
   SelectedRecord.MARKEDONLY(TRUE);
   IF NOT SelectedRecord.FINDFIRST THEN BEGIN // if no records were selected
      FormMyRecordList.GETRECORD(ActiveRecord); // select active record
      MESSAGE('No recors were selected, but we still can use active record');
   END ELSE BEGIN // if at least one item was selected
      REPEAT
         MESSAGE('Some items were selected');
         // do something for each selected record
      UNTIL SelectedRecord.NEXT = 0;
   END;
END; // << IF FormMyRecordList.RUNMODAL = ACTION::LookupOK THEN BEGIN

// NAVISIONARY 22/11/2009 <<

But then I remembered, that instead of reinventing the wheel I should have tried using default Navision functionality. We can select more than one G/L Account when we are adding them to account schedules (Function > Insert Account Schedules). Actual code can be found in Codeunit 8 "AccSchedManagement", function InsertGLAccounts().

On the other hand, sometimes it feels good to do something on your own, doesn't it?

Technorati Tags: , ,

This entry was posted in Dynamics NAV / Navision and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *