SetSelectionFilter and temporary Records

Schwarz
Schwarz Member Posts: 8
Hello,

i tried to use the Currform.Setselectionfilter Function in a form with temporary records. Looks like that on temporary records this function
doesnt work :D

Did someone have some experience with this behaviour or are there some possible workarounds to use the SetselectionFilter Function.

Thanks for your help in advantage.

Regards.

Comments

  • ara3n
    ara3n Member Posts: 9,258
    Add a new boolean field called Select. The user will then check the records he wants to select. and you can then filter on that field.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Schwarz
    Schwarz Member Posts: 8
    Hello ara3n,

    of cource thats a possible solution and i was thinking about this, but using SetSelectionfilter is a more "Windows like" style and some customers prefer this way.

    I use Setselectionfilter in several cases and it works fine, i didnt thouht that it doesnt work with temporary records.

    Using the Record mark is another way to solve the problem. But there are some problems using Citrix (which can be solved..)

    Regards,
    Frank
  • ara3n
    ara3n Member Posts: 9,258
    Yes temp records have some limitations and Navision never fully implemented all of the features of a regular record.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • MTC
    MTC Member Posts: 159
    I've just actually found this problem with temporary records. I was doing a little test here at home when a colleague of mine was having problems getting it to work. So, I just wrote this:
    OBJECT Table 51000 testing
    {
      OBJECT-PROPERTIES
      {
        Date=14/11/06;
        Time=20:35:21;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
      }
      FIELDS
      {
        { 1   ;   ;num                 ;Integer        }
        { 2   ;   ;testing                ;Integer        }
        { 3   ;   ;testing2               ;Integer        }
      }
      KEYS
      {
        {    ;num                                      }
      }
      CODE
      {
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 51000 testinglauncher
    {
      OBJECT-PROPERTIES
      {
        Date=14/11/06;
        Time=22:24:13;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=2200;
        Height=550;
      }
      CONTROLS
      {
        { 1000000000;CommandButton;0;0  ;2200 ;550  ;Name=Launch;
                                                     OnPush=BEGIN
                                                              FORM.RUNMODAL(FORM::testing,testinger)
                                                            END;
                                                             }
      }
      CODE
      {
        VAR
          testinger@1000000000 : TEMPORARY Record 51000;
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 51001 testing
    {
      OBJECT-PROPERTIES
      {
        Date=14/11/06;
        Time=22:39:49;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=6710;
        Height=4400;
        SourceTable=Table51000;
        OnOpenForm=VAR
                     c@1000000000 : Integer;
                   BEGIN
                     DELETEALL;
    
                     FOR c := 0 TO 100 DO BEGIN
                         INIT;
                         num := c;
                         testing := c * 2;
                         testing2 := c * 5;
                         INSERT;
                     END;
                   END;
    
      }
      CONTROLS
      {
        { 1000000000;TableBox;220 ;110  ;6270 ;3520  }
        { 1000000002;TextBox;0    ;440  ;1700 ;440  ;ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=num }
        { 1000000003;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000002;
                                                     InColumnHeading=Yes }
        { 1000000004;TextBox;1376 ;440  ;1700 ;440  ;ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=testing;
                                                     OnActivate=BEGIN
                                                                  recr.GETTABLE(Rec);
                                                                  fieldr := recr.FIELD(Rec.FIELDNO(testing));
                                                                END;
                                                                 }
        { 1000000005;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000004;
                                                     InColumnHeading=Yes }
        { 1000000006;TextBox;3837 ;330  ;1700 ;440  ;ParentControl=1000000000;
                                                     InColumn=Yes;
                                                     SourceExpr=testing2;
                                                     OnActivate=BEGIN
                                                                  recr.GETTABLE(Rec);
                                                                  fieldr := recr.FIELD(Rec.FIELDNO(testing2));
                                                                END;
                                                                 }
        { 1000000007;Label  ;0    ;0    ;0    ;0    ;ParentControl=1000000006;
                                                     InColumnHeading=Yes }
        { 1000000001;CommandButton;220;3740;2200;550;Name=But;
                                                     OnPush=VAR
                                                              i@1000000001 : Integer;
                                                              pap@1000000002 : Record 51000;
                                                              c@1000000003 : Integer;
                                                              trecr@1000000005 : RecordRef;
                                                              tfieldr@1000000004 : FieldRef;
                                                            BEGIN
                                                              CurrForm.SETSELECTIONFILTER(pap);
                                                              pap.MARKEDONLY(TRUE);
    
                                                              IF NOT pap.FINDFIRST THEN BEGIN
                                                                  i := fieldr.VALUE;
                                                                  i *= 2;
                                                                  fieldr.VALUE(i);
                                                                  recr.MODIFY;
                                                              END
                                                              ELSE BEGIN
                                                                  REPEAT
                                                                      trecr.GETTABLE(pap);
                                                                      FOR c := 2 TO 3 DO BEGIN
                                                                          tfieldr := trecr.FIELD(c);
                                                                          i := tfieldr.VALUE;
                                                                          i *= 2;
                                                                          tfieldr.VALUE(i);
                                                                          trecr.MODIFY;
                                                                      END;
                                                                  UNTIL pap.NEXT = 0;
                                                              END;
                                                            END;
                                                             }
      }
      CODE
      {
        VAR
          recr@1000000000 : RecordRef;
          fieldr@1000000001 : FieldRef;
    
        BEGIN
        END.
      }
    }
    

    When testinger at the end of Form 51000 is set as not being TEMPORARY, the SETSELECTIONFILTER works fine, when TEMPORARY however, it simply will not enter the part of the code that deals with a selected line. The SETSELECTIONFILTER simply returns nothing.

    It's all a bit strange IMO, because the form is working totally with Rec, it's not a workaround dealing with OnFindRecord or OnNextRecord manually, the TEMPORARY Record is declared in the calling form. The actual addressing of the table data really should not matter, it should be going through exactly the same function set as if it were in the database, surely this is wrapped up. It doesn't however.

    Is there any other was of knowing which line is selected? I think that it's impossible without workarounds such as Bool checkboxes. Real shame.
  • ara3n
    ara3n Member Posts: 9,258
    Yep I was doing this a few days ago to see if they've changed anything in 4.0 sp3 and ran into the same problem. I'm afraid you still need to add a boolean. The other option is to add a GUID to the Primary key and insert the records into the table.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • MTC
    MTC Member Posts: 159
    Are we sure the reason for this is because they haven't implemented it fully? Could it not simply be a bug that they are unaware of?
  • ara3n
    ara3n Member Posts: 9,258
    Yes of course it's a bug, you can try to ask MS. But I don't know if you'll get anywhere. If there is a workaround, it's not critical and they won't fix it. Specially now that we will have a new client in v. 5.0.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n