web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Bulk delete quotes

(0) ShareShare
ReportReport
Posted on by 36
Hello, is there a way to bulk delete / void old quotes by user, by year?
 
thanks
Categories:
I have the same question (0)
  • Suggested answer
    lancebrigham Profile Picture
    119 on at
    Hi Virgilio,
     
    There's not a way of doing this that I'm aware of. Of course, you could go one-by-one assigning the ones you want to delete to a specific batch and then delete the batch, but I'm guessing this isn't feasible due to the number of quotes at play and is why you're asking the question. You can go the SQL route if you're comfortable doing so. This will be a bit more involved. At a high level, you're removing records at least from SOP10100 and SOP10200 and possibly other tables too; for example, SOP10106 if you have these transactions have user-defined field values or SOP10202 if you have line level comments etc. Since you'd be removing directly via SQL you'd also need to do batch cleanup in SY00500 (I believe just NUMOFTRX and BCHTOTAL).
     
    In SQL, you'd probably want YEAR(DOCDATE) and/or USER2ENT to determine year quote was entered and/or what user originally entered the quote.
     
    In SmartList, this would be the Document Date and/or User To Enter fields filtered on SOP Type=Quote.
     
    At a high level, getting started on SQL route could look something like this for a year cutoff approach. 
     
    DECLARE @YearCutoff INT=2021
     
    UPDATE BatchHeader
    SET 
        NUMOFTRX-=QuoteSumByBatch.NUMOFTRX,
        BCHTOTAL-=QuoteSumByBatch.DOCAMNT_SUM
    FROM SY00500 BatchHeader
        INNER JOIN (
            SELECT BACHNUMB,COUNT(*) NUMOFTRX,SUM(DOCAMNT) DOCAMNT_SUM
            FROM SOP10100
            WHERE SOPTYPE=1 AND YEAR(DOCDATE)<=@YearCutoff 
            GROUP BY BACHNUMB
        ) QuoteSumByBatch ON BatchHeader.BACHNUMB=QuoteSumByBatch.BACHNUMB

    WHERE BatchHeader.BCHSOURC='Sales Entry'
    DELETE SOPLine
    FROM SOP10200 SOPLine
        INNER JOIN SOP10100 SOPHeader ON SOPLine.SOPNUMBE=SOPHeader.SOPNUMBE AND SOPLine.SOPTYPE=SOPHeader.SOPTYPE
    WHERE SOPHeader.SOPTYPE=1 AND YEAR(SOPHeader.DOCDATE)<=@YearCutoff 
     
    DELETE SOPUserDef
    FROM SOP10106 SOPUserDef
        INNER JOIN SOP10100 SOPHeader ON SOPUserDef.SOPNUMBE=SOPHeader.SOPNUMBE AND SOPUserDef.SOPTYPE=SOPHeader.SOPTYPE
    WHERE SOPHeader.SOPTYPE=1 AND YEAR(SOPHeader.DOCDATE)<=@YearCutoff 
     
    DELETE SOPLineComments
    FROM SOP10202 SOPLineComments
        INNER JOIN SOP10100 SOPHeader ON SOPLineComments.SOPNUMBE=SOPHeader.SOPNUMBE AND SOPLineComments.SOPTYPE=SOPHeader.SOPTYPE
    WHERE SOPHeader.SOPTYPE=1 AND YEAR(SOPHeader.DOCDATE)<=@YearCutoff 
     
    DELETE SOP10100 
    WHERE SOPTYPE=1 AND YEAR(DOCDATE)<=@YearCutoff 
     
    This works in my test environment. If you decide to try this, exercise extreme caution and run an isolated test environment first.
     
    Let me know if any questions.
     
    Thanks,
    Lance Brigham
    Principal Consultant
    Velosio

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 669 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 384 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans