Delete multiple lines in the same sales order

sbillysbilly Member Posts: 231
Hi all,
I want to create a function that deletes multiple lines in the same sales order. How can I push the system to delete selected lines ( selection with ctrl button) like we select lines with ctrl and push the delete button of the keyboard.
Any suggestions please?

Comments

  • vijay_gvijay_g Member Posts: 884
    First, Why you want to do this..?

    what you have tried till now? There should not be any problem if you are technical.
  • sbillysbilly Member Posts: 231
    To answer ur first question:
    After importing many sales lines from a csv file, I want to delete some of them in the same time.

    My problem is how to make the system delete only the selected lines (selection with ctrl)
  • vijay_gvijay_g Member Posts: 884
    Make a button and write this code on Onpush trigger.
    CurrForm.SETSELECTIONFILTER(RecVar);
    RecVar.DELETEALL;
    
    RecVar is Variable type of record(36,37);
  • sbillysbilly Member Posts: 231
    Thanks for help :)
  • David_SingletonDavid_Singleton Member Posts: 5,479
    vijay_g wrote:
    Make a button and write this code on Onpush trigger.
    CurrForm.SETSELECTIONFILTER(RecVar);
    RecVar.DELETEALL;
    
    RecVar is Variable type of record(36,37);

    [-X

    Please do not do this, this code can corrupt your database.
    David Singleton
  • ReinhardReinhard Member Posts: 249
    David, can you provide any more info on that? Seems like that would be an important thing to know!
  • sbillysbilly Member Posts: 231
    Hi David,
    Please tell me why this code can corrupt the database?
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Create a sales order.

    Ship any line.

    Now run your code.

    The database is now corrupt.

    And this is just one example, the simplest, there are plenty more cases where this code will corrupt the database.
    David Singleton
  • David_SingletonDavid_Singleton Member Posts: 5,479
    vijay_g wrote:
    _________________
    Vijay Gupta
    Changing the code is last step. Try to change processes first...

    Vijay,

    please read your signature, in it lies the correct solution to this question.
    David Singleton
  • sbillysbilly Member Posts: 231
    Thank you for the clarification, if I understand, this code will delete any thing in the database without respect of navision rules?
  • MBergerMBerger Member Posts: 413
    Why not use Deleteall(true) ?
  • dansdans Member Posts: 148
    why do you need a delete button to delete the selected lines ???
    Microsoft Certified IT Professional for Microsoft Dynamics NAV

    Just a happy frood who knows where his towel is
Sign In or Register to comment.