New line in-between the lines

snehasneha Member Posts: 191
Hi Experts,

Can we restrict users from entering a new line in-between the lines?

Usually System automatically generates a line number as 10000,20000,……..
Client considering a line number as 1,2…. And always want that line number must be in sequence.
But somehow users entering a new line in-between the lines, when user enters a new line in-between 10000 and 20000, system automatically generating a line number as 15000. How can we restrict the users from entering a new line in-between the lines?

Answers

  • KarenhKarenh Member Posts: 209
    In the OnInsert trigger of the line table you could add code like below:


    Line2.SETRANGE("Document Type","Document Type");
    Line2.SETRANGE("Document No.","Document No.");
    Line2.SETFILTER("Line No.",'>%1',"Line No.");
    IF NOT Line2.ISEMPTY THEN
    ERROR('You cannot add an in-between line');


    Line2 is a variable type Record for the Line table. You need to add it as a local variable, to the OnInsert trigger.
  • garakgarak Member Posts: 3,263
    or, if you need it ever at the end, try this:
    OnInsert() 
    //OnInsert in MyTable
    MyTableAsVariable.RESET;
    MyTableAsVariable.SETFILTER(Primarykeyfields,Values);
    IF MyTableAsVariable.FINDlast THEN
      "Line No." := MyTableAsVariable."Line No." + 10000;
    

    regards
    Do you make it right, it works too!
  • mohana_cse06mohana_cse06 Member Posts: 5,504
  • garakgarak Member Posts: 3,263
    can't we set AutoSplitKey to False :-k

    Then the "line No." is 0
    Do you make it right, it works too!
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    garak wrote:
    can't we set AutoSplitKey to False :-k

    Then the "line No." is 0

    Yes garak,you are right #-o

    Thanks
  • garakgarak Member Posts: 3,263
    so, if he really want it, that no line should be inserted (per hand) between line 10000 and line 20000 u must use the OnInsert solution (the standard does this also do, for example in table 5741).

    But explain the customer, what for an comfort then he lost.
    Do you make it right, it works too!
  • snehasneha Member Posts: 191
    Thank you Karenh and garak
  • garakgarak Member Posts: 3,263
    Please and welcome
    Do you make it right, it works too!
Sign In or Register to comment.