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, ...
Answered

Sales orders clean up doesn't work as expected

(3) ShareShare
ReportReport
Posted on by 308
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:
I have the same question (0)
  • Layan Jwei Profile Picture
    8,124 Super User 2025 Season 2 on at
    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
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,449 Super User 2025 Season 2 on at
    Hi @Migi,
     
    You can also use (YearRange(-6,-6)) method to select all order in 2019.
     
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Migi Profile Picture
    308 on at
    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
    26,449 Super User 2025 Season 2 on at
    Hi @Migi,
     
    In this case you need to run the process in batch job.
     
    Best regards,
    Mohamed Amine MAHMOUDI
     
  • Migi Profile Picture
    308 on at
    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. 
  • Layan Jwei Profile Picture
    8,124 Super User 2025 Season 2 on at
    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
  • Layan Jwei Profile Picture
    8,124 Super User 2025 Season 2 on at
    Hi,
     
    Is your question answered?
  • Verified answer
    Migi Profile Picture
    308 on at
    We ended up customizing standard functionality. 

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