Options

to allow multiple values in a text field in navision

jksjks Member Posts: 277
Hello,

I am using one text filed. For that text field i have set TableRelation property to one table name.

Now i want that text field to hold multiple value. How can i do that?

Please help.

Comments

  • Options
    bbcaibbcai Member Posts: 80
    Define global variable and pass value in it
  • Options
    kinekine Member Posts: 12,562
    I do not understand what you want to reach. You want to have more Codes from the linked table in one field in one record??? No, it is not possible - if you have field connected to another table, you can have only one value from the connected table there... if you want something as filter in the field, you must disable relation test on the field and create your own OnLookup etc...

    Please, post more details...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jksjks Member Posts: 277
    How can i do that?

    With my text field arrow symbol is attached because of that TableRelation propery. Whenever i click that arrow symbol, one lookup window will get opened. Data in that lookup window will come from some another table.

    I want to select multiple values from that lookup window and want to assign all those values to that text field.

    How can i do that?

    Please help.
  • Options
    kinekine Member Posts: 12,562
    It is not so simple and as I can see, you are not enough skilled, but I can try to direct you to some code which can help you...

    If you go to the Budgets form, to the G/L Account filter, when you click the arrow, select more lines, click OK, there will be Filter entered, which include all the values, you selecte... you can be inspired with this...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jksjks Member Posts: 277
    Thanks for your help.

    I saw the code. When i click that arrow values selected by me will be stored in one variable and those selected values will be displayed in the matrix box. Am i right?

    But what i want is whatever values i select those values should get stored in the table field.
    e.g
    Suppose my table name is Customer and it has one field named Segment then wheneve i select multiple values from that lookup table all those values should get stored in Segment field of Customer table.

    Please help.
  • Options
    kinekine Member Posts: 12,562
    it is same: inplace variable you have field... inplace OnLookup on the edit box, you have OnLookup on your Field... same concept...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jksjks Member Posts: 277
    Can i do the same by providing a command button next to the text field.
    So when i click on command button lookup table will appear and i will select the multiple values from it.
  • Options
    kinekine Member Posts: 12,562
    It's on you, where you will call the code... OnLookup, OnDrilldown, OnPush...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    DenSterDenSter Member Posts: 8,304
    Can't you set the ValidateTableRelation and the TestTableRelation properties to No? That way you still have the lookup into the other table, but you can enter what you want.
  • Options
    kinekine Member Posts: 12,562
    But you are not able to select more values through standard Lookup...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    DenSterDenSter Member Posts: 8,304
    Right, so you want to lookup value A, then value B, and have both of them show up. I guess you could teach users to copy the A value before they look up value B and paste it in, but that is not very user friendly is it ;)
  • Options
    jksjks Member Posts: 277
    Can i do the following?

    I will provide one command button next to the text field. Then PushAction property of that button will be set to RunObject and RunObject property will be set to Table table_name . Now in that table i will have two fields, one will contain the data that i want to insert in the text field and second field will contain checkboxes. so when i click on that command button , lookup table will appear and then i will check those checkboxes whose corresponding first field values i want.

    Can i do this?
    if yes then how. i.e. Which trigger should i use? How can i find out which checkboxes are selected?
    Please help
  • Options
    kinekine Member Posts: 12,562
    You must think that more than one user can click the button and check the checkboxes... you must use temp table or have some sort of filtering to user than... solution is to call the form through form variable, in this way:
      FormVar.SETTABLEVIEW(FilteredRecord);  //set what you want to show
      FormVar.LOOKUPMODE := true;
      IF FormVar.RUNMODAL = ACTION::LookupOK THEN BEGIN
        ListForm.GetRecords(FilteredRecord);
        if FilteredRecord.FIND('-') then
        repeat
          if Txt <> '' then
            Txt := Txt + '|';
          Txt := Txt + FilteredRecord.Field;  //result in Txt will be 'Val1|Val2|Val3'
        until FitleredRecord.NEXT=0;
      END;
    

    Code in form:
    GetRecords(VAR Param : Record YourTable)
      CurrForm.SETSELECTIONFILTER(Param);  //copy selection filter to the param
    

    It will include all values which you (user) select - all blue records...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jksjks Member Posts: 277
    Thanks.

    Now i am able to select the multiple values. But one problem is there.
    I am assigning selected multiple values to one variable. Now how can i transfer the value of that variable to a field of a table.

    I have written following code for that. No error is there but value doesn't get transferred from variable to field in a table.


    segval:=segcode.getvalue(); // segval is a variable
    searchin.OPEN(18);// table 18 contains the field to which i want to assing value
    searchin.NEXT();
    searchinfield:=searchin.FIELD(2);
    searchinfield.VALUE(FORMAT(segval));
    COMMIT;
  • Options
    HalMdyHalMdy Member Posts: 429
    jks wrote:
    Thanks.

    segval:=segcode.getvalue(); // segval is a variable
    searchin.OPEN(18);// table 18 contains the field to which i want to assing value
    searchin.NEXT();
    searchinfield:=searchin.FIELD(2);
    searchinfield.VALUE(FORMAT(segval));
    COMMIT;


    1. COMMIT not mandatory
    2. You have to "save" the record after modification with searchin.MODIFY
  • Options
    kinekine Member Posts: 12,562
    1) why you are using RecordRef inplace Record? Do you need to asign the value to more tables or it is everytime table 18?

    2) you must call MODIFY to save modifications... do not use COMMIT if you have no necessity ... (as HalMdy wrote...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jksjks Member Posts: 277
    It worked.

    Thanks.

    Now instead of writing a code can i do the same by setting property.
    i.e. can't i directly assign value of the variable to the field, by setting the SourceExpr and TableRelation property so that i need not to first find out the correct record and then to insert value of variable to a field.
  • Options
    DenSterDenSter Member Posts: 8,304
    FormVar.SETTABLEVIEW(FilteredRecord);  //set what you want to show
      FormVar.LOOKUPMODE := true;
      IF FormVar.RUNMODAL = ACTION::LookupOK THEN BEGIN
        ListForm.GetRecords(FilteredRecord);
        if FilteredRecord.FIND('-') then
        repeat
          if Txt <> '' then
            Txt := Txt + '|';
          Txt := Txt + FilteredRecord.Field;  //result in Txt will be 'Val1|Val2|Val3'
        until FitleredRecord.NEXT=0;
      END;
    
    This will cause overflow errors once the length of all the records' fields exceeds the length of Txt. You should program a check for the string length in the loop, to prevent that error.
  • Options
    jksjks Member Posts: 277
    Is there any method by which i can set reference to a particular record(i.e. i can retrieve the record) based on the primary key?

    (without going through a loop and without using recordref.next())

    Thanks for any help.
  • Options
    DenSterDenSter Member Posts: 8,304
    When you know the primary key values, you use the GET method to retrieve the record. Otherwise you set filters and you loop through a set of records.
  • Options
    jksjks Member Posts: 277
    It worked.

    Thanks.
Sign In or Register to comment.