Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Getting Error while trying to save the report a PDF in local drive using save dialog

Posted on by Microsoft Employee

Hi all,

I am getting the following error while trying to save the report as pdf using save dialog .

Please let me know how to resolve it ?

" Error opening the file ‘C:\Program Files\Microsoft Dynamics AX\.0\client\appl\standard\’.
File Not found. "

Below is My Code :

public void init()
{

this.printJobSettings().setTarget(PrintMedium::File);
this.printJobSettings().preferredFileFormat(PrintFormat::PDF);
this.printJobSettings().fileName(fileName);
super();

}

}

----------------------------------------------------------------------------------------------

public PrintMedium setTarget(PrintMedium _target)
{
PrintMedium ret;

ret = super(PrintMEdium::File);

return ret;
}

----------------------------------------------------------------------------------------------------

public boolean printerSettings(int _showWhat=-1)
{
boolean ret;

ret = super(_showWhat);

return ret;
}

-----------------------------------------------------------------------------------------------------------

public Object dialog(Object _dialog)
{
Dialog d = super(_dialog);
df = d.addFieldValue(typeid(FileNameSave), "Select file to save");
d.filenameLookupFilter(["PDF Files","*.pdf"]);
d.filenameLookupTitle("Select filename and type");
df.value(df.value());
fileName = df.value();
return d;
}

-------------------------------------------------------------------------------------------------------

public class ReportRun extends ObjectRun
{
CompanyInfo companyInfo;
tmp_InventTableModule tModules;
test_PrintDataCustPrcList testPrcList;
// dialog d ;//= new dialog("Select file");
PrintJobSettings printJobSettings;
dialogField df;
FileName fileName;
}

---------------------------------------------------------------------------------------------------------

public void run()
{
this.printJobSettings().setTarget(PrintMedium::File);
this.printJobSettings().fileName(fileName);

this.printJobSettings().format(PrintFormat::PDF);
super();
}

---------------------------------------------------------------------------------------

PLEASE LET ME KNOW WHAT AM I DOING WRONG HERE . I DON'T NO WHY THAT ERROR IS COMING UP AND HOW TO RESOLVE IT ?

PLEASE HELP

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: Getting Error while trying to save the report a PDF in local drive using save dialog

    Microsoft Mania, you're forgetting about the debugger. If you looked at what value you put into this.printJobSettings().fileName(), you would have immediately seen that it's wrong (if the error message wasn't clear enough) and therefore you have a problem in setting the value of filename.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: Getting Error while trying to save the report a PDF in local drive using save dialog

    You do need to retrieve the filename value entered by the user. It seems to be empty now, having AX using a default directory as file name.

    The file name in your error message is:  ‘C:\Program Files\Microsoft Dynamics AX\.0\client\appl\standard\’ This is a filepath only; no filename is known for AX currently.

    So the code "fileName = df.value();" needs to set on another place. You are now using it on initiation of the dialog.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Getting Error while trying to save the report a PDF in local drive using save dialog

    Hi Andre,

    DO I need to create the method.  it's not a override method right?

    But Why am I getting that Error Please let me know ?

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: Getting Error while trying to save the report a PDF in local drive using save dialog

    Hi,

    Do you also have a method "getFromDialog" implemented? This should read the value entered by the user.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans