Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / How to Delete a PO Lin...
Finance forum
Unanswered

How to Delete a PO Line without a PO Header

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
    Navneeth Nagrajan 1,347 Super User 2024 Season 2 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
    André Arnaud de Cal... 290,326 Super User 2024 Season 2 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
    Martin Dráb 228,166 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.
  • 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
    Martin Dráb 228,166 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?
  • 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
    Martin Dráb 228,166 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.
  • How to Delete a PO Line without a PO Header
    @Leah Ju, I am using Microsoft Dynamics 365 Finance/Operations.
  • Leah Ju Profile Picture
    Leah Ju 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?

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,326 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,166 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans