Announcements
Hi community,
I would like to delete a record from ProdTable (Production Order table) and all of related information from other tables (if any).
The normal way is: open "All production orders" record list, chose a record then press Delete button. The record is deleted well without any error message. Follow this way, after deleting I went to "View >> Net requirement >> Overview Tab" and saw that the associated record is also deleted.
However by doing this programatically, after deleting record from ProdTable, when going to "View >> Net requirement >> Overview Tab" I saw that the associated record still be there. Source code for deleting is:
ProdTable.doDelete();
So my understanding is when Delete button is pressed, the record from ProdTable is deleted and all of other related record from other tables are deleted as well. I looked at the method that is being called on Delete button and saw that is "Delete Record" (command). But unfortunately I can't find where this method is defined.
Is my understanding correct? If yes, where could I find the definition of "Delete Record" command? If not, how could I delete a record from ProdTable correctly? Please help.
Any help would be appreciated. Thank you all.
Wall-e.
*This post is locked for comments
Thank all for your help.
As my investigation so far, when using prodTable.delete() all of related records in other tables will be deleted as well. Other tables could be declared in DeleteAction node with properties "cascade".
According to my issue, the record in reqTrans was not deleted because the record in prodTable was not deleted successfully. In prodTable, only records with status "Created" could be deleted. If the current status is not Created, it must be reset to Created before perform delete action.
After I added a processing of reset status, then the record in ReqTrans table was deleted successfully. In fact, the code should be as:
- reset status of prodTable record to Created
- ProdTable.delete()
Again, thank you all for your support.
I tested this. I created a production order. View -> Net requirements showed records. In ReqTrans, a record was created where RefId was referring to my new ProdId.
I deleted the production order from the user interface with Delete button. Then I checked ReqTrans with table browser. The requirement record was still there. So it seems that it's not deleted in either case. So the x++ code is working identically with the process that was started from the user interface.
I think that rerunning Master Planning (for that item) will anyway refresh ReqTrans and clean such leftover rows. But I'm a technical person, not a production / master planning specialist so I might not be 100% correct. At least for me running MP for that item cleaned the orphan entry from ReqTrans.
In prodTable check the delete actions node is there any delete action defined for reqTrans table. Delete actions works in three different ways so if its set to cascade then deleting the record from prodTable will also delete corresponding record from reqTrans table. You can check more about delete actions from msdn.
I am not in front of computer otherwise I could conform this.
Thank you all for your help.
I have followed Nikolaos's suggestion but unfortunately the problem still be there. Taking a look into this method, it just deletes the record from ProdTable and from PmfProdCoby table. That's all.
Further step in my investigation, the data shown on "Net Requirement" screen is stored in ReqTrans table. But I didn't find any method (of ProdTable) where ReqTrans record is deleted when ProdTable is deleted. So I think there's would be somewhere they defined the Business Logic processing for deleting a record from ProdTable.
Do you all have any idea about button Command "Delete Record"? Where could I find the definition for this?
Thank you.
Hi wall-e ,
Please look in to below link,
https://msdn.microsoft.com/en-us/library/aa624886.aspx
Thanks
Suresh
Definition of doDelete on MSDN:
msdn.microsoft.com/.../aa628085.aspx
And as suggested above, use delete() unless you want to ignore the business logic in there, which probably takes care of what you were missing.
You should use
prodTable.delete() instead of prodTable.doDelete().
If you call doDelete() it will skip all the code that exists in the delete() method.
Calling the delete() method corresponds to clicking the Delete button on the user interface. In addition to that, in some cases there might be some additional code in the ProdTable form data source, so you could check that as well.
But most likely calling delete() method will do the trick for you.
André Arnaud de Cal...
294,069
Super User 2025 Season 1
Martin Dráb
232,858
Most Valuable Professional
nmaenpaa
101,158
Moderator