Calling procedures in a middle of transaction

babak2000ir
Member Posts: 5
I'm stocked somewhere fellas,
Imagine a header-Lines structure, by validating some fields on the lines, I'll call a procedure to update header (procedure will look at the lines to update header based on the line values), when I call the procedure, procedure query the line table, but as I called the procedure during the line transaction, new changes are not stored yet.
I used Commit, but apparantly commit is not working inside the Modify Trigger.
I also taught about checking a flag while changing the line, and call the procedure later, as procedure changes something inside the header, I cannot call it on Page or List (onAfterGetRecord), I'll get a error.
Would you please give me some Ideas?
Imagine a header-Lines structure, by validating some fields on the lines, I'll call a procedure to update header (procedure will look at the lines to update header based on the line values), when I call the procedure, procedure query the line table, but as I called the procedure during the line transaction, new changes are not stored yet.
I used Commit, but apparantly commit is not working inside the Modify Trigger.
I also taught about checking a flag while changing the line, and call the procedure later, as procedure changes something inside the header, I cannot call it on Page or List (onAfterGetRecord), I'll get a error.
Would you please give me some Ideas?
0
Comments
-
COMMIT works fine inside an OnModify trigger. But the record isn't modified in the table before the OnModify trigger is finished. You often make additional changes to the Rec inside an OnModify trigger, then it wouldn't make sense if it is modified in the table before the OnModify trigger. If you need to call a function that requires the record to be modified, you will simply need to call MODIFY without TRUE ;-) inside your OnModify trigger. Just make sure the rest of your code supports it. It might cause problems for the Change Log, if that is enabled for the table...
Edit: An even better solution might be to pass the record as a parameter to the function, but it depends on the needs.Regards
Peter0 -
Never use COMMIT in your code.
The only place it makes sense it if you are writing your own posting routine. Or you are batch processing.0 -
pdj wrote:COMMIT works fine inside an OnModify trigger. But the record isn't modified in the table before the OnModify trigger is finished. You often make additional changes to the Rec inside an OnModify trigger, then it wouldn't make sense if it is modified in the table before the OnModify trigger. If you need to call a function that requires the record to be modified, you will simply need to call MODIFY without TRUE ;-) inside your OnModify trigger. Just make sure the rest of your code supports it. It might cause problems for the Change Log, if that is enabled for the table...
Edit: An even better solution might be to pass the record as a parameter to the function, but it depends on the needs.
Even without testing I'm sure this works, Thank you, I will confirm if it worked for me
The process is really independent so sending rec as a refrence was not possible, but problem completely solved, abd thank you for the heads up about: Just make sure the rest of your code supports it. this is so important, Really thanks, you helped me a lot0 -
ara3n wrote:Never use COMMIT in your code.
The only place it makes sense it if you are writing your own posting routine. Or you are batch processing.
Thanks, I'll have it in my mind. I believe this is true, sometimes it really tickles me to use Commit, but I usually try to avoid, this Commit thing is kind of like "GOTO"!0 -
[Topic moved from 'NAV Three Tier' forum to 'NAV/Navision Classic Client' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
So, if a COMMIT has been used in CU-2 called from CU-1 and in CU-2 there is an error, is the data written in CU-2, stored to the database or is there a rollback after the error and nothing is written to the db, so like:
CU-1:
.
.
IF not CU-2 then //CU-2 contains a COMMIT
UpdateError;
.Roelof de Jonghttp://www.wye.com0 -
If CODEUNIT.RUN Then automatically issues a commit.0
-
Any time that a COMMIT is called it writes everything to the database. If you run into an error later, it will roll back to the last COMMIT. You could write code that 'fixes' any data that you're left with after half of a transaction, but technically that is NOT a rollback.0
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