How to get Previous Row,Next Row values while Insert Line ?

pskannaapskannaa Member Posts: 138
HI,
I need to get the values of Previous and Next row values while inserting the Line Item..why because if im going to insert the Line Item in exiting records I NEED TO CHECK BEFORE ROW TYPE AND AFTER ROW TYPE, IF IT'S 'EXT TEXT' THEN DO NOT ALLOW USER TO INSERT THOSE LINE.

Type Description......
ITEM AAAAAAA
EXT.TEXT XXXXXXXXX
EXT.TEXT YYYYYYYYYY {In between row of Ext.TExt i do not want to allow to Insert the Line
EXT.TEXT ZZZZZZZZZZ

So, Condition to check while insert trigger, how...??

Regards,
Psk

Comments

  • sresre Member Posts: 62
    Hi Psk,

    how about something like that in the OnInsert-Trigger:
    temp1.RESET;
    temp1.SETFILTER(ID, '<%1', ID);
    IF NOT temp1.FIND('+') THEN
      temp1.INIT;
    
    temp2.RESET;
    temp2.SETFILTER(ID, '>%1', ID);
    IF NOT temp2.FIND('-') THEN
      temp2.INIT;
    
    IF (temp1.TYPE = 'EXT') OR (temp2.TYPE = 'EXT') THEN
      ERROR('');
    

    temp1 and temp2 are the same table on which you want to perform the insert. Determine the previous and the subsequent line and check e.g. the field "type" to determine if the record should be inserted or not.

    Regards
    Sascha
  • sresre Member Posts: 62
    [edit] Sent the same reply twice, sorry ...
  • kinekine Member Posts: 12,562
    pskannaa wrote:
    HI,
    I need to get the values of Previous and Next row values while inserting the Line Item..why because if im going to insert the Line Item in exiting records I NEED TO CHECK BEFORE ROW TYPE AND AFTER ROW TYPE, IF IT'S 'EXT TEXT' THEN DO NOT ALLOW USER TO INSERT THOSE LINE.

    Type Description......
    ITEM AAAAAAA
    EXT.TEXT XXXXXXXXX
    EXT.TEXT YYYYYYYYYY {In between row of Ext.TExt i do not want to allow to Insert the Line
    EXT.TEXT ZZZZZZZZZZ

    So, Condition to check while insert trigger, how...??

    Regards,
    Psk

    Nearly same problem was posted one week ago: viewtopic.php?f=23&t=33756&p=164104
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.