CU 1 - OnDatabase methods

nboettcher
Member Posts: 14
I have placed a call to my own code unit within the OnDatabaseInsert, OnDatabaseModify and OnDatabaseDelete methods in CU 1.
However, I have found these methods are only being called if I have the Change Log turned on for the particular table.
1. Is there a way to modify to make those methods always get fired?
2. Where is the code that calls those methods?
3. Is there a way to create my own "global" on database change methods in CU1 that will fire for any change?
However, I have found these methods are only being called if I have the Change Log turned on for the particular table.
1. Is there a way to modify to make those methods always get fired?
2. Where is the code that calls those methods?
3. Is there a way to create my own "global" on database change methods in CU1 that will fire for any change?
0
Comments
-
These triggers are fire automatically from the page by NAV behind the scenes so we do not have control over these functions. Although these functions are fired for pages they are not fired when changes are made via code logic (i.e. Processing reports, etc). I do not know of a way to create global functions but we can use these functions and piggyback on the logic as does the InteractionManagement in NAV 2013. What version are you currently using and can you give a little detail around what it is you are trying to accomplish, there may be another method to approach the challenge.Tim Whitaker | Senior NAV Consultant/Developer | The Software Workshop Ltd. | http://www.thesoftwareworkshop.com0
-
whitaker_tim: that's not true for OnDatabase Triggers, it was like this in the old OnGlobal Triggers (only called by user interactions) but now with the new triggers, they are fired on every database change!
Here is more info about it:
http://www.dynamics.is/?p=869
http://msdn.microsoft.com/en-us/library/gg502491.aspx
BTW: Whyt you need to to is, you need your own TriggerMask Logic, see the Integration Mgt. how they did it. The OnDatabase Triggers are fired based on these TriggerMasks that is requested in the GetDatabaseTableTriggerSetup() Function (CU1).0 -
Thank you for the clarification of details, it is certainly helpful that these now fire no matter whether code or user interaction.Tim Whitaker | Senior NAV Consultant/Developer | The Software Workshop Ltd. | http://www.thesoftwareworkshop.com0
-
Hi Guys
This routine works great in 2009RecordChangeLog() TableBasePtr (DATABASE::"Payment Terms", 4, 1, 1, 'CLS', lxRecRef); lPayTerms.GET ('CLS'); lPayTerms."Discount %" := 6; lPayTerms.MODIFY; TableBasePtr (DATABASE::"Payment Terms", 4, 1, 1, 'CLS', lRecRef); lChangLogMgt.OnGlobalModify (lRecRef, lxRecRef); lRecRef.CLOSE; lxRecRef.CLOSE; TableBasePtr(pTableNo : Integer;pFieldNo : Integer;pKeyIndex : Integer;pKeyField : Integer;pPrimaryField : Code[10];VAR pRecRef : Recor pRecRef.OPEN (pTableNo); IF pRecRef.WRITEPERMISSION () = FALSE THEN ERROR ('Can write to %1', pRecRef.NAME); lKeyRef := pRecRef.KEYINDEX (pKeyIndex); lFieldRef := lKeyRef.FIELDINDEX (pKeyField); lFieldRef.SETRANGE (pPrimaryField); IF pRecRef.FIND ('-') THEN BEGIN lFieldRef := pRecRef.FIELD (pFieldNo); IF lFieldRef.ACTIVE = FALSE THEN ERROR ('Could not Activate Field %1 in Table No. %2', pFieldNo, pTableNo); END;
But has anybody created the same senario in NAV 2013R2, where you wish to record Change Log Entries for records changes in Code? The following didn't work...RecordChangeLog() lPayTerms.GET ('CLS'); lPayTerms."Discount %" := 11; lPayTerms.MODIFY; TableBasePtr (DATABASE::"Payment Terms", 4, 1, 1, 'CLS', lRecRef); lChangLogMgt.OnDatabaseModify (lRecRef); lRecRef.CLOSE; PAGE.RUN (PAGE::"Change Log Entries"); TableBasePtr(pTableNo : Integer;pFieldNo : Integer;pKeyIndex : Integer;pKeyField : Integer;pPrimaryField : Code[10];VAR pRecRef : RecordRef) pRecRef.OPEN (pTableNo); IF pRecRef.WRITEPERMISSION () = FALSE THEN ERROR ('Can write to %1', pRecRef.NAME); lKeyRef := pRecRef.KEYINDEX (pKeyIndex); lFieldRef := lKeyRef.FIELDINDEX (pKeyField); lFieldRef.SETRANGE (pPrimaryField); IF pRecRef.FIND ('-') THEN BEGIN lFieldRef := pRecRef.FIELD (pFieldNo); IF lFieldRef.ACTIVE = FALSE THEN ERROR ('Could not Activate Field %1 in Table No. %2', pFieldNo, pTableNo); END;
With thanksBig D signing off!0 -
Just did some tests with 2016 and the OnDataBaseDelete trigger.
It seems that it only works if the ChangeLog is enabled.
(and service tier has to be restarted after setting changelog)0 -
whitaker_tim: that's not true for OnDatabase Triggers, it was like this in the old OnGlobal Triggers (only called by user interactions) but now with the new triggers, they are fired on every database change!
Here is more info about it:
http://www.dynamics.is/?p=869
http://msdn.microsoft.com/en-us/library/gg502491.aspx
BTW: Whyt you need to to is, you need your own TriggerMask Logic, see the Integration Mgt. how they did it. The OnDatabase Triggers are fired based on these TriggerMasks that is requested in the GetDatabaseTableTriggerSetup() Function (CU1).
Cool stuff, thanks for sharing (and thanks to the author). I think i stayed away from mibuso for too long0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions