Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Sales orders clean up doesn't work as expected

(3) ShareShare
ReportReport
Posted on by 270
Hi, we have huge salestable and salesline -tables from capacity point of view and would like to delete older sales orders. So for this purpose there is 'Delete sales order' -functionality (Sales and marketing/Periodic tasks/Clean up). First I have to select the sales orders to be deleted:
If I choose e.g. sales orders created before 2019 the query goes like this:
 
And here's the problem: When I press OK, it starts to process the request and it just keeps going and going. Yesterday I waited for 2 hours but it didn't finish. 
Question: What are my options now? I don't prefer going to SQL because I think deleting orders this way is more safe and it probably deletes everything related to sales orders.
Categories:
  • Verified answer
    Migi Profile Picture
    270 on at
    Sales orders clean up doesn't work as expected
    We ended up customizing standard functionality. 
  • Layan Jwei Profile Picture
    7,725 Super User 2025 Season 1 on at
    Sales orders clean up doesn't work as expected
    Hi,
     
    Is your question answered?
  • Layan Jwei Profile Picture
    7,725 Super User 2025 Season 1 on at
    Sales orders clean up doesn't work as expected
    Hi Migi,
     
    Try to divide it by selecting orders for a certain year
    I mean between 2018 and 2019 and delete
    Then 2017 and 2018...etc
  • Migi Profile Picture
    270 on at
    Sales orders clean up doesn't work as expected
    No, you don't understand. First I have the press Select to filter the orders to be deleted. And that query takes long time to finish. When that's completed, I can choose batch job to delete those rows. 
    But that Select-query takes ages to be executed and I should be waiting the whole time, because if the session gets closed I have to start all over again. I think I'll ask from the developer if it can be speed-up somehow. 
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    17,598 Super User 2025 Season 1 on at
    Sales orders clean up doesn't work as expected
    Hi @Migi,
     
    In this case you need to run the process in batch job.
     
    Best regards,
    Mohamed Amine MAHMOUDI
     
  • Migi Profile Picture
    270 on at
    Sales orders clean up doesn't work as expected
    Hi, 
    Thank you for your answers. I managed to get results out of one single day in 2019, but it took 10 minutes to process it. I also used 'invoiced' as status filter. So the main problem still remains. If I want to delete all the orders from 2019 it would take days to process it. 
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    17,598 Super User 2025 Season 1 on at
    Sales orders clean up doesn't work as expected
    Hi @Migi,
     
    You can also use (YearRange(-6,-6)) method to select all order in 2019.
     
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Layan Jwei Profile Picture
    7,725 Super User 2025 Season 1 on at
    Sales orders clean up doesn't work as expected
    Hi,

    I feel the syntax you put for filters is wrong

    maybe use 1/1/2019 instead of 1.1.2019
     
    they way you filtered status also looks wrong as the open order syntax looks wrong


    As a start try to delete orders created in one day by putting this created date time 12/30/2018..1/1/2019
    and maybe just orders with status invoiced

    make sure this works then make the query cover larger data

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,245 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans