Running report from the OnModify trigger

bab
Member Posts: 65
I have a problem, when running a report from the OnModify trigger of a table.
The situation is: when a record changes i need to send a notyfication e-mail. The attachment is a html file generated by a report.
When I run a report (SAVEASHTML) from the OnModify trigger, it seems, that the report runs the OnModify trigger of the table, and falls is recursion.
I tried it on several tables/reports.
Has anybody met this problem?
The situation is: when a record changes i need to send a notyfication e-mail. The attachment is a html file generated by a report.
When I run a report (SAVEASHTML) from the OnModify trigger, it seems, that the report runs the OnModify trigger of the table, and falls is recursion.
I tried it on several tables/reports.
Has anybody met this problem?
0
Answers
-
Nobody met this problem?
Other things: SQL2005, and NAV400 without any SP.0 -
Hi bab
I just tried to save a report as htlm from the OnModify trigger and my computer locked up. It took my 5-10 minutes to kill Navision.
I don't know what is happening and I won't repeat the test
I guess we can conclude that we shouldn’t try to save reports as html from the OnModify trigger. Have you tried to solve the issue differently?
You could just send a email from the OnModify trigger and then link to the report or include the required information in the body of the email.
Regards
Claus0 -
Yes, I think I will send a simple e-mail, but the reason was, why I tried to do this way, because if I send a report by mail, the SalesPerson doesn't need to login to navision.
Anybody else can solve this problem?0 -
Create a function on sales line called skipsendingreport. In the function set a global variable DONNOTSENDREPORT to true.
Before running the modify(true) statement call the function.
In onmodify trigger run the report only if DONNOTSENDREPORT is set to false.0 -
I tried it several times, it does not work.
My last try was:
ReportSended: Boolean (Global scope)
OnModifyRecord trigger of the form (SourceTable: T5050 (Contact)):
run the report if the ReportSended is FALSE, and set it TRUE.
And what i thought is impossible: it falls in recursion too. It seems, that the report runs this trigger too, and the "IF NOT ReportSended THEN" takes no effect... :?:0 -
create a field then on the line and modify it to true once you've sent the email. Only send the email if field is checked false.0
-
Maybe it works, but this is only a half solution: When will this field became FALSE?0
-
hmm in your report you can do a modify without the true paramater.0
-
I will try it, and post the result here.
thx0 -
Finally it works :!:
Added a new Field in the T5050 (Contact) Notification Sent - Boolean
Created a report (Contact - Card), in the OnAfterGetRecord trigger:"Notification Sent" := FALSE; MODIFY;
Added a new function - NotifyByMail to the T5050:Contact.RESET; Contact.SETRANGE("No.", "No."); FileName := ENVIRON('TEMP') + '\' + DELCHR(USERID, '=', ' ') + '.html'; IF FILE.EXISTS(FileName) THEN FILE.ERASE(FileName); ContactCard.SETTABLEVIEW(Contact); "Notification Sent" := TRUE; ContactCard.SAVEASHTML(FileName); SMTPMail.NewMessage('noreply@xx.xx', STRSUBSTNO(Text80000, USERID, "No.")); SMTPMail.SetWorkMode; SMTPMail.SetHost(CompanyInfo."SMTP Server"); SMTPMail.AddLine(Text80001); SMTPMail.SetToAdress(SalesRecSetup."Notify Email on Contact Change"); SMTPMail.AddAttachment(FileName); SMTPMail.Send; FILE.ERASE(FileName);
In the OnModify trigger of the table:IF NOT "Notification Sent" THEN NotifyByMail;
Thanks all!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