Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 release wave 1 Discover the latest updates and new features to Dynamics 365 planned through September 2020
Release overview guides and videos Release Plan | Preview 2020 Release Wave 1 Timeline
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
I know this is probably a basic thing I am over looking, but cannot get it to work. Basically, in our setup, users are able to delete orders with items that are shipped but not invoiced. We want to be able to prevent this from happening. I placed code in the OnBeforeDelete trigger of the Service Line table, but it still is letting the record be deleted. My code is below.
if ("Quantity Shipped" > "Quantity Invoiced")
then Error('Cannot Delete Line %1 because there are lines Shipped not Invoiced',"Line No.");
I also want to know if I put this code in the line level, and they click delete on the header level of the order, will it stop and prevent all lines from being deleted.
There is no OnBeforeDelete, if you are planning to subscribe to that event then it should like below
LOCAL [EventSubscriber] OnBeforeDelete(VAR Rec : Record "Service Line";RunTrigger : Boolean)
I may not be understanding you but there is a trigger for OnBeforeDelete? So I do not know what I am doing wrong based on your response.
Where did you add the above code? in the table?
Yes in the Service Line Table I added that. Trying to prevent service orders from getting deleted when they have quantities shipped not invoiced.
Can you please send the screenshot of it, there is a OnDeleteTrigger but not OnBeforeDelete, OnBeforeDelete is the event which you have to subscribe.
Per your request see screen shot of available triggers for a Table Extension. (I removed my previous code)
Those are subscriber events, you need to subscribe to them. Create a codeunit a subscribe for ex: for the table sales line for OnBeforeModifyEvent, do similar for service line OnBeforeDelete
[EventSubscriber(ObjectType::Table, 37, 'OnBeforeModifyEvent', '', false, false)]
local procedure OnBeforeModify(var Rec: Record "Sales Line"; RunTrigger: Boolean)
SalesHeader: Record "Sales Header";
if not RunTrigger then
SalesHeader.Get(Rec."Document Type", Rec."Document No.");
Business Applications communities