passing parameter and run report modal(repID,false,false,rc)

Mr_Nemo
Member Posts: 6
Hi all,
Thanks in advance ..
I have a form where I have a command button, by clicking on it a report will automatically run and will be saved as a pdf in the given path. The report has a request option form, there are two variables, where I need to pass parameters while running it from the form. I have done this by writing a few codes.. but the problem is I dont want to show the ReqWindow or anything, the whole process should be done automatically while clicking on the button. But if I use reportvariable.runmodal it will open the window, and if I use report.runmodal(reportID,false,false,recordvariable), then it is not working... please help..here are my codes.
IF ISCLEAR(BullZipPDF) THEN
CREATE(BullZipPDF);
ReportID:=50028;
FileDirectory := 'C:\New Folder\';
FileName := 'test'+'.pdf';
Object.GET(Object.Type::Report,'',ReportID);
recSalesInvHeader.RESET;
recSalesInvHeader.SETRANGE(recSalesInvHeader."Publication Type",'01');
recSalesInvHeader.SETRANGE(recSalesInvHeader."Posting Date",140511D);
IF recSalesInvInvHeader.FINDSET THEN BEGIN
BullZipPDF.Init;
BullZipPDF.LoadSettings;
RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE);
BullZipPDF.SetValue('Output',FileDirectory+FileName);
BullZipPDF.SetValue('Showsettings', 'never');
BullZipPDF.SetValue('ShowPDF', 'no');
BullZipPDF.SetValue('ShowProgress', 'no');
BullZipPDF.SetValue('ShowProgressFinished', 'no');
BullZipPDF.SetValue('SuppressErrors', 'yes');
BullZipPDF.SetValue('ConfirmOverwrite', 'no');
BullZipPDF.WriteSettings(TRUE);
RepAddBill.PassParam('01',140511D); // this is the func of the report pasing 2 parameters
REPORT.RUNMODAL(ReportID,FALSE,FALSE,recSalesInvHeader);
//RepAddBill.RUNMODAL;
TimeOut := 0;
WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN
SLEEP(1500);
TimeOut := TimeOut + 1;
END;
END;
Thanks in advance ..
I have a form where I have a command button, by clicking on it a report will automatically run and will be saved as a pdf in the given path. The report has a request option form, there are two variables, where I need to pass parameters while running it from the form. I have done this by writing a few codes.. but the problem is I dont want to show the ReqWindow or anything, the whole process should be done automatically while clicking on the button. But if I use reportvariable.runmodal it will open the window, and if I use report.runmodal(reportID,false,false,recordvariable), then it is not working... please help..here are my codes.
IF ISCLEAR(BullZipPDF) THEN
CREATE(BullZipPDF);
ReportID:=50028;
FileDirectory := 'C:\New Folder\';
FileName := 'test'+'.pdf';
Object.GET(Object.Type::Report,'',ReportID);
recSalesInvHeader.RESET;
recSalesInvHeader.SETRANGE(recSalesInvHeader."Publication Type",'01');
recSalesInvHeader.SETRANGE(recSalesInvHeader."Posting Date",140511D);
IF recSalesInvInvHeader.FINDSET THEN BEGIN
BullZipPDF.Init;
BullZipPDF.LoadSettings;
RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE);
BullZipPDF.SetValue('Output',FileDirectory+FileName);
BullZipPDF.SetValue('Showsettings', 'never');
BullZipPDF.SetValue('ShowPDF', 'no');
BullZipPDF.SetValue('ShowProgress', 'no');
BullZipPDF.SetValue('ShowProgressFinished', 'no');
BullZipPDF.SetValue('SuppressErrors', 'yes');
BullZipPDF.SetValue('ConfirmOverwrite', 'no');
BullZipPDF.WriteSettings(TRUE);
RepAddBill.PassParam('01',140511D); // this is the func of the report pasing 2 parameters
REPORT.RUNMODAL(ReportID,FALSE,FALSE,recSalesInvHeader);
//RepAddBill.RUNMODAL;
TimeOut := 0;
WHILE EXISTS(RunOnceFile) AND (TimeOut < 10) DO BEGIN
SLEEP(1500);
TimeOut := TimeOut + 1;
END;
END;
0
Comments
-
Mr Nemo wrote:But if I use reportvariable.runmodal it will open the window, and if I use report.runmodal(reportID,false,false,recordvariable), then it is not working...
Try the example code from Rashed in the thread How to save Navision Reports as PDF or his blog http://mibuso.com/blogs/ara3n/2008/08/0 ... ts-to-pdf/ .No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)0 -
@Luc Van Dyck, thanks for your reply....
well the problem is, when I am using simple reports say for exp - (customer-list) where there is no request form, only request filter field, it is working fine using runmodal by setting the reqwindow false... as I told you I want the whole thing will be done automatically.. but in my report there are two dataitems, and a few filters which have been done in the onpre dataitem using setrange and setfilter and I have applied a few filter in the properties as well... in that case it's not working, the system hangs for few seconds, perhaps it's because of the sleep time...but no pdf is generated at all.... I hope I am able to make you understand.
Thanks a lot... and i have gone through this link earlier, even I have used it few times before.. I know that I have done something wrong or missed something but can't resolve it...0 -
Hi,
Your problem is that you created a report variable to pass the parameters and then you call it by the ReportID. This will not work.BullZipPDF.SetValue('ConfirmOverwrite', 'no'); BullZipPDF.WriteSettings(TRUE); CLEAR(RepAddBill); RepAddBill.PassParam('01',140511D); // this is the func of the report pasing 2 parameters //REPORT.RUNMODAL(ReportID,FALSE,FALSE,recSalesInvHeader); RepAddBill.SETTABLEVIEW(recSalesInvHeader); RepAddBill.USEREQUESTFORM(FALSE); RepAddBill.RUNMODAL; CLEAR(RepAddBill);
This should work. Be sure to clear your RepAddBill variable, because you're running it modally.
Hope this helps,
Regards,
WillyFostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.0 -
KYDutchie wrote:Hi,
Your problem is that you created a report variable to pass the parameters and then you call it by the ReportID. This will not work.BullZipPDF.SetValue('ConfirmOverwrite', 'no'); BullZipPDF.WriteSettings(TRUE); CLEAR(RepAddBill); RepAddBill.PassParam('01',140511D); // this is the func of the report pasing 2 parameters //REPORT.RUNMODAL(ReportID,FALSE,FALSE,recSalesInvHeader); RepAddBill.SETTABLEVIEW(recSalesInvHeader); RepAddBill.USEREQUESTFORM(FALSE); RepAddBill.RUNMODAL; CLEAR(RepAddBill);
This should work. Be sure to clear your RepAddBill variable, because you're running it modally.
Hope this helps,
Regards,
Willy
Hi KYDutchie,
It works, thanks a lot..I overlooked the USEREQUESTFORM property, that's why I kept trying to run it using reportID. Anyways thanks a ton..0 -
You are welcome. Glad I could help.
please mark the topic as solved.
thanks,
WillyFostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.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