Deleting all empty orders

siimsandsiimsand Member Posts: 28
Hello!

In the table Sales Header (36) there are orders. Double-clicking on them opens the Sales Order (42) page for this order. There are fasttabs General, Lines, etc... I've created a button for deleting all orders that have 'empty' Lines. I have this code with a user prompt for Yes/No:

UserPrompt := CONFIRM(Text001, FALSE);
IF UserPrompt = TRUE THEN BEGIN
IF SalesHeader.FINDSET() THEN BEGIN
REPEAT
// TODO - if page 'Lines' empty, then...
UNTIL SalesHeader.NEXT = 0;
END;
END;

Any directions or ideas on how to code this?

Best Answer

  • siimsandsiimsand Member Posts: 28
    Answer ✓
    AK wrote: »
    That depends on your definition of "empty". Do you want to delete all Sales Headers without sales lines?
    //TODO
      Salesline.setrange("Document Type",SalesHeader."Document Type");
      Salesline.setrange("Document No.",SalesHeader."No.");
      if SalesLine.isempty then
        SalesHeader.Delete;
    

    Yes, they are to be deleted entirely. Thank you for your answer!

Answers

  • AKAK Member Posts: 226
    edited 2018-01-17
    That depends on your definition of "empty". Do you want to delete all Sales Headers without sales lines?
    //TODO
      Salesline.setrange("Document Type",SalesHeader."Document Type");
      Salesline.setrange("Document No.",SalesHeader."No.");
      if SalesLine.isempty then
        SalesHeader.Delete;
    
  • siimsandsiimsand Member Posts: 28
    Answer ✓
    AK wrote: »
    That depends on your definition of "empty". Do you want to delete all Sales Headers without sales lines?
    //TODO
      Salesline.setrange("Document Type",SalesHeader."Document Type");
      Salesline.setrange("Document No.",SalesHeader."No.");
      if SalesLine.isempty then
        SalesHeader.Delete;
    

    Yes, they are to be deleted entirely. Thank you for your answer!
Sign In or Register to comment.