Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to Delete a PO Line without a PO Header

(0) ShareShare
ReportReport
Posted on by 8
I'm trying to delete an erroneous PO Line for which the PO Header has already been deleted. As shown in the attached screenshot, this PO Line (line 30) on PO #(Anonymized) populates in our purchase order lines database, but if we try to click into the PO Header name (PO#Anonymized), it shows no such PO. This PO Line will not be erased if I try alt+delete for the record. Essentially there should be no such PO Line, and it's impeding accuracy in our database (since there's a PO Line that should not be there). How can I delete this PO Line without a parent PO Header?
  • Navneeth Nagrajan Profile Picture
    1,937 Super User 2025 Season 1 on at
    How to Delete a PO Line without a PO Header
    Hi,
     
    Martin's script is correct but it looks like there have been PO Headers that have been deleted forcefully or altered without the PO Lines being validated or deleted? This can happen if the PO is an Open Purchase order. Looks like a script has been fired from the database (In case of a non-production environment) to forcefully remove the Purchase order header.
     
    Happy to answer questions, if any.
     
     
  • André Arnaud de Calavon Profile Picture
    295,853 Super User 2025 Season 1 on at
    How to Delete a PO Line without a PO Header
    Hi,
     
    Can you tell us if your question has been solved in the meantime? If so, it would be great if you could mark answers that helped you. If not, feel free to update your question with your latest observations. We then might be able to help you.
  • Martin Dráb Profile Picture
    234,597 Most Valuable Professional on at
    How to Delete a PO Line without a PO Header
    I don't see All PO Lines form, but it's likely that it doesn't allow record deletion at all (it's the case of the Backorder purchase lines form, for instance). You didn't answer my question about the deletion, but I guess this is the cause.
     
    Deleting a record is, usually, very simple. Something like this:
    ttsbegin;
    
    PurchLine purchLine = PurchLine::findRecId(123456, true);
    purchLine.delete();
    
    ttscommit;
    But it's quite possible that it'll fail in this case if there is no header.
     
    You could delete the line directly by doUpdate() or in database, but I wouldn't do it without careful analysis. For example, there may be inventory transactions and if we deleted the order line and not them, we would just shift the data inconsistency somewhere else instead of fixing it.
  • Community member Profile Picture
    8 on at
    How to Delete a PO Line without a PO Header
    @Martin Dráb Sorry for not clarifying--this PO Line is visible within the "All PO Lines" form, which is inclusive of all lines across different headers. but if I try to click into the specific PO Header itself for that particular line, listed as the "parent" of this "stray" line, it shows no such header--just a blank field where the full PO Header view would normally be available.
     
    I agree with you that it doesn't make sense that a PO Line would remain an entry in our PO Lines without a parent header I can modify--this is not normally the case, which is why I posted this inquiry, because I have not had this issue before. The fact that this "phantom" PO Line exists within our PO Lines is impacting our summary data compiled via export, which is why I'm hoping to delete it.
     
    Do you have an example of a script I could use or a resource I could visit to learn how to draft a script which would navigate past the GUI and address this issue?
     
    Thank you kindly for the context you've already provided, I appreciate this info. 
  • Martin Dráb Profile Picture
    234,597 Most Valuable Professional on at
    How to Delete a PO Line without a PO Header
    I don't understand how you can see that in the Purchase orders form. There you see lines for the selected header and if you have no header to select, how you can see its lines?
  • Community member Profile Picture
    8 on at
    How to Delete a PO Line without a PO Header
    @Martin Dráb I'm in the "Procurement and Sourcing" Module within Purchase Orders, typically I'd be able to cancel the deliver remainder and it would effectively cancel the PO--however, I can only access that functionality when the Purchase Order is accessible from the PO Headers View.
  • Martin Dráb Profile Picture
    234,597 Most Valuable Professional on at
    How to Delete a PO Line without a PO Header
    Moved from Dynamics 365 general forum.
     
    Which form are you talking about? Does it allow deletion at all? What happens when you try to delete the line?
     
    In general, it's quite often such corrupted data can't be fixed through GUI, because the application is designed to work with a consistent database. Therefore you may need a script to deal with it.
  • Community member Profile Picture
    8 on at
    How to Delete a PO Line without a PO Header
    @Leah Ju, I am using Microsoft Dynamics 365 Finance/Operations.
  • Leah Ju Profile Picture
    Microsoft Employee on at
    How to Delete a PO Line without a PO Header
    Hi Partner,
    Could you tell me what app you are using in Dynamics 365?

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 565

#2
Martin Dráb Profile Picture

Martin Dráb 536 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 402 Super User 2025 Season 1

Product updates

Dynamics 365 release plans