Dimension Value Lookup

CobaltSSCobaltSS Member Posts: 137
Hi all,

I think I've forgotten something. Stop laughing. We have a report of which the "Dimension Value" table is a data item. I would like to include the Code field on the Request Form, and have the user choose from a Lookup form the values to be picked. But there's no Lookup arrow. The table does have a LookupFormID (Form 560 - Dimension Value List). And the Form runs well by itself, but I can't get it attached to the field on the Request Form of the report. The Primary Key for Dimension Value table is Dimension Code,Code; I would like to limit the values shown in the form to a specific Dimension Code.

Any advice greatly appreciated.

cheers,

Comments

  • kinekine Member Posts: 12,562
    1) You can use OnLookup of the Editbox to enter the code to open the lookup form and select the value
    2) You can use TableRelation property of the editbox to connect it to specific table (bat you cannot include filter based on some settings or another variable).

    I recommend the first option...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • CobaltSSCobaltSS Member Posts: 137
    Hi Kamil,

    Thanks for your help. Here's the Code I wrote for the DeptFilter (Text 200) on the Request Form:
    Dimension Value - OnLookup(VAR Text : Text[1024];) : Boolean
    DeptFilterHolder := DeptFilter;
    "Dimension Value".SETFILTER("Dimension Code", 'DEPARTMENT');
    IF FORM.RUNMODAL(560, "Dimension Value") = ACTION::LookupOK THEN BEGIN
      IF STRLEN(DeptFilter) > 0 THEN BEGIN
        CASE Connector OF
          Connector::Range: DeptFilter := DeptFilterHolder + '..' + "Dimension Value".Code;
          Connector::Unique: DeptFilter := DeptFilterHolder + '|' + "Dimension Value".Code;
        END;
      END ELSE BEGIN
        DeptFilter := "Dimension Value".Code;
      END;
    END;
    

    I'm having an issue with applying the Text as a filter, but I think I can resolve it.

    cheers,
  • i4tosti4tost Member Posts: 208
    Instead of "DeptFilter :=" use "Text :=" and do not forget to have a line EXIT(true)
  • kinekine Member Posts: 12,562
    "cleaned" code (but take it as a tip, not correction... ;-))
    Dimension Value - OnLookup(VAR Text : Text[1024];) : Boolean
    GLSetup.GET;
    "Dimension Value".SETFILTER("Dimension Code", GLSetup."Shortcut Dimension x Code");
    IF FORM.RUNMODAL(FORM::"560", "Dimension Value") = ACTION::LookupOK THEN BEGIN
      IF STRLEN(Text) > 0 THEN BEGIN
        CASE Connector OF
          Connector::Range: Text := Text + '..' + "Dimension Value".Code;
          Connector::Unique: Text := Text + '|' + "Dimension Value".Code;
        END;
      END ELSE BEGIN
        Text := "Dimension Value".Code;
      END;
      Exit(True);
    END ELSE
      Exit(False);
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • CobaltSSCobaltSS Member Posts: 137
    Hi Kamil,

    I don't mind getting spanked when I deserve it.
    SETFILTER(Code, '%1', DeptFilter);
    

    This line in the PreDataItem generates a "There is no Dimension Value within the filter" error if I try to apply a filter that uses either ".." or the "|". A single value does not generate an error.

    Any advice greatly appreciated.

    cheers,
  • kinekine Member Posts: 12,562
    Of course, because 3rd and other parameters must be just single value from the table. If you want to use the value as filter, you need to insert is as a 2nd parameter - it means:
    SETFILTER(Code, DeptFilter); 
    

    And I do not want to spank anyone... 8)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.