Open Forum

Expand all | Collapse all

Delete all Sales Quotes

  • 1.  Delete all Sales Quotes

    SILVER CONTRIBUTOR
    Posted 20 days ago
    Hi All,
    Is there a clean way to delete all sales quotes from NAV? I see that report 5179 "Delete Sales Quote Versions" deletes all archived sales quotes. Would I clone this report and modify to delete all sales quotes, both archived and not-archived? If so, what code to I change exactly?

    Here is the C/AL for current report 5179:


    ---------------------------------------------------------------------------------------------------------------------------------------------------
    --------------------------------------------------------BEGINNING OF CODE BLOCK-------------------------------------------------
    ---------------------------------------------------------------------------------------------------------------------------------------------------


    Sales header Archive - OnPreDataItem()                                                                                                                                                                                                    
    Sales header Archive - OnAfterGetRecord()                                                                                                  
    SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type"::Quote);
    SalesHeader.SETRANGE("No.","No.");
    SalesHeader.SETRANGE("Doc. No. Occurrence","Doc. No. Occurrence");
    IF NOT SalesHeader.FINDFIRST THEN
    DELETE(TRUE);

    Sales Header Archive - OnPostDataItem()                                                                                                       

    ---------------------------------------------------------------------------------------------------------------------------------------------------
    --------------------------------------------------------END OF CODE BLOCK-----------------------------------------------------------
    ---------------------------------------------------------------------------------------------------------------------------------------------------


    As always, your help is greatly appreciated!

    -Matt

    ------------------------------
    Matt Cameron
    Marine Ingredients
    Mount Bethel PA
    ------------------------------


  • 2.  RE: Delete all Sales Quotes

    TOP CONTRIBUTOR
    Posted 20 days ago
    ​I don't see a function to delete all sales quotes, so you could take the logic from Report 5179 and create a new report with that logic on tables 36 (Sales Header) and 37 (Sales Lines).  Just be sure that you are only deleting records with a Document Type of "Quote"


    ------------------------------
    Lewis Rosenberg
    IT Manager
    Mars Fishcare
    Chalfont PA
    -----------------------------------------------
    BCUG/NAVUG All-Star
    BCUG/NAVUG Board of Advisors, Chairperson
    BCUG/NAVUG Programming Committee

    Twitter: @RosenbergL
    LinkedIn: https://www.linkedin.com/in/rosenbergl/
    ------------------------------



  • 3.  RE: Delete all Sales Quotes

    TOP CONTRIBUTOR
    Posted 19 days ago
    You could create a new report, a processing only report that would delete table records but make sure that you add conditions for Quotes only.

    ------------------------------
    Kristoffer Ruyeras
    Tigunia
    Seattle, WA
    ------------------------------



  • 4.  RE: Delete all Sales Quotes

    GOLD CONTRIBUTOR
    Posted 19 days ago
    I think it will be simple enough to do with code like this -

    SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type"::Quote);
    IF SalesHeader.FINDSET THEN
      SalesHeader.DELETEALL(TRUE);


    ** I would recommend to do it in the TEST Database.
    ** with this it might archive sales quote if its set enabled in Sales and Receivable setup. (Field - "Archive Quotes")

    ------------------------------
    Saurav Dhyani
    ArcherPoint Inc.
    Duluth GA
    ------------------------------



  • 5.  RE: Delete all Sales Quotes

    TOP CONTRIBUTOR
    Posted 18 days ago

    Matt, you can use the same report as a new report. Adjust some coding not required.

    Just remember change the DataItem to point to Sales Header, remove the property (DataItemTableView) and make sure its filtered on "Document Type"=Quote.
    In the coding OnAfterGetRecord(), change it this.
    IF "Document Type" = "Document Type"=Quote THEN
      DELETE(TRUE);

    Note: The (TRUE) is important to carry out deleting related records!

    Run it against a specific Quote No. Make sure you trace any related records that should have gotten deleted.

    Good luck.



    ------------------------------
    Geovanny Fuentes
    San Diego CA
    ------------------------------