Bojensen Blogs

Kategori: Microsoft Dynamics Ax

How to Assert multiple file IO permission

  server static void CAP_copyFile(FilenameOpen _attachmentFilename, str _attachmentsFolder){Set permissionSet; ; // Revert permissionsCodeAccessPermission::revertAssert();permissionSet = new Set(Types::Class);permissionSet.add(new FileIoPermission(_attachmentFilename,’r’));permissionSet.add(new FileIoPermission(_attachmentsFolder,’w’));CodeAccessPermission::assertMultiple(permissionSet);// Move to processed folder// BP Deviation Documented winAPI::copyFile(_attachmentFilename,_attachmentsFolder,true);CodeAccessPermission::revertAssert();} H K Srikanth Dynamics Axapta Blog: How to Assert multiple file IO permission

An alternative to the WinApi functions

  The WinApi class holds some nice functions for file manipulation, like the WinApi::fileExistsWinApi::copyFileWinApi::deleteFileWinApi::moveFile I think every programmer has used one of those functions in Ax at one time or another, as they can be really helpful. They have one big drawback though: They need to be executed on the client tier. Trying to use…

Stack trace: Invalid attempt to call WinAPI::findFirstFile running in CIL on the client.

This error you will normally encounter when running a batch job. The issue is that batch processing doesn’t suppport WINAPI::findFirstFile method. Actually I was trying to find a file in the folder and moving to some other folder, you can use this alternative: public void run(){    System.IO.DirectoryInfo di;    System.Type arrayType;    System.Array array;    System.IO.FileInfo fi;    FilePath…

X++ code to Count Records in Query

  Following code illustrates how we can use SysQuery::countTotal() method to get the number of records in Query. static void Query_cntRecords(Args _args) {     Query                query = new Query();     QueryRun             queryRun;     QueryBuildDataSource qbd;     ;     qbd = query.addDataSource(tablenum(CustTable));     queryRun = new QueryRun(query);     info(strfmt("Total Records in Query %1",SysQuery::countTotal(queryRun))); } Microsoft Dynamics…

Dynamics Ax Internals: Quick walk-through of developing a report in Ax2012

The following is a quick-and-dirty approach to building a basic SSRS report in Ax2012. This uses an Ax query as the primary datasource, and uses display methods on the table(s) to retrieve additional information. This is not an approach you should take for all reports, particularly those that require more complex calculations or parameters, but…