Marking records on a lookup form and using MARKEDONLY

cssgyulacssgyula Member Posts: 31
Hi,

I am creating a field in which the user can create a filter expression. I have declared a text[250] variable and I don't allow the user to create a larger expression than that.

For the selection of multiple records I thought I will use the marking of records on the lookup form. My testcode looks like this.
CLEAR(MyRecVariable);
IF FORM.RUNMODAL(0,MyRecVariable)=ACTION::LookupOK THEN
   BEGIN
      MESSAGE(FORMAT(MyRecVariable.COUNT));
      MyRecVariable.MARKEDONLY(TRUE);
      MESSAGE(FORMAT(MyRecVariable.COUNT));
   END;

I tried this code under NAV 4.0 and NAV 4.0 SP3, but I found out that the count of records before calling the MARKEDONLY are all records in the table, but after initiating the MARKEDONLY command, the count is always zero although there were records marked manually on the lookup form.

Further problems are, that I cannot go through all of the marked records, I can only asses the currently highlighted one on the lookup form, so I cannot collect the field values which are MARKED by the user on the lookup form.

What am I doing wrong?

The C/SIDE help says:
Example
This example shows how to use MARK and MARKEDONLY. You should assume that initially none of the records are marked.

Customer.SETCURRENTKEY("No.");
Customer."No." := 'NEW 3500';
Customer.FIND('=');
Customer.MARK(TRUE); // Mark a record

No1 := Customer.COUNT;
Customer.MARKEDONLY(TRUE);
No2 := Customer.COUNT;
MESSAGE(Text000 + Text001, No1, No2);

Create the following text constants in the C/AL Globals window:

Text Constant
ENU Value

Text000
'Number of records before MARKEDONLY: %1\'

Text001
'Number of records after MARKEDONLY: %2'


The message window could show:

Number of records before MARKEDONLY: 5
Number of records after MARKEDONLY: 1

Thanks for your help,
Best Regards,

Gyula (Jules) Csiák-Sedivy

There are two things, which you cannot learn from books. True love and Software Coding.

Comments

  • PeterDPeterD Member Posts: 66
    Did you highlight multiple lines in the form or did you mark them with CTRL-F1?
  • babbab Member Posts: 65
    Szia,
    this will only work, if you create an instance from the form you want to use, and a function on the form, with a parameter type record (passed by reference), which marks the records in the parameter, as the records are marked on the form.
    I mean for examlpe you want the user to mark Sales Quotes:
    Create a form (or use the "Sales List"), and add a function:
    GetRecord(VAR SalesHeader : Record "Sales Header")
    RESET;
    SalesHeader.CLEARMARKS;
    IF FINDFIRST THEN
      REPEAT
        SalesHeader.GET("Document Type", "No.");
        SalesHeader.MARK(MARK);
      UNTIL NEXT = 0;
    SalesHeader.MARKEDONLY(TRUE);
    
    and you can use it like this:
    SalesList.LOOKUPMODE := TRUE;
    SalesHeader.FILTERGROUP(6);
    SalesHeader.SETRANGE("Document Type", SalesHeader."Document Type"::Quote);
    SalesHeader.FILTERGROUP(0);
    SalesList.SETTABLEVIEW(SalesHeader);
    IF SalesList.RUNMODAL = ACTION::LOOKUPOK THEN BEGIN
      SalesList.GetRecord(SalesHeader);
      MESSAGE(FORMAT(SalesHeader.COUNT));
    END;
    
    Hope this helps.
Sign In or Register to comment.