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

Mr_NemoMr_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;

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    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...
    Please explain "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)
  • Mr_NemoMr_Nemo Member Posts: 6
    @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...
  • KYDutchieKYDutchie Member Posts: 345
    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
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • Mr_NemoMr_Nemo Member Posts: 6
    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.. :)
  • KYDutchieKYDutchie Member Posts: 345
    You are welcome. Glad I could help.

    please mark the topic as solved.

    thanks,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
Sign In or Register to comment.