web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Request for the permission of type 'FileIOPermission' failed.

(0) ShareShare
ReportReport
Posted on by

Hi All,

I need some help in my ax 2009 batch job.

Here I attached image of error1033.Error.jpg

Here is the involved classes:

ATM_BATCH
run
public void run()
{
ATM_Interface generate = new ATM_Interface();
;
permission = new InteropPermission(Interopkind::ClrInterop);
permission.assert();

generate.run();

}


ATM_INTERFACE
run
public void run()
{
;
ATM_Interface::ImportFromATM();
}

ATM_INTERFACE
ImportfromATM
public static boolean ImportFromATM()
{
InterfaceFileDirectory iFileDirectory;
LedgerJournalTable ledgerJournalTable;
LedgerJournalTrans ledgerJournalTrans;
utcdatetime dateNow;
date nowDate;
TransDate transDate;
str strDate, strTransDate, description;
Amount amountDebit, amountCredit;

CommaIo csvFileHeader, csvFileLines;
Filename filenameH, filenameL;
container readCon1, readCon2;
NumberSequenceTable numberSequenceTable;
Voucher voucher;
LedgerJournalCheckPost ledgerJournalCheckPost;
Set permissionSet;
;
//initialize
amountDebit = 0;
amountCredit = 0;

//select directory path of the ATM output file
dateNow = System.DateTime::get_Now();
nowDate = datetimeutil::date(dateNow);
strDate = date2str(nowDate,321,2,0,2,0,4);
SELECT * FROM iFileDirectory
WHERE iFileDirectory.InterfaceCode == "ATM";
filenameH = iFileDirectory.InterfaceFilePath + "\\ATMH_" + strDate + ".txt";
filenameL = iFileDirectory.InterfaceFilePath + "\\ATML_" + strDate + ".txt";


csvFileHeader = new CommaIo(filenameH, 'rw');
csvFileLines = new CommaIo(filenameL, 'rw');


readCon1 = csvFileHeader.read();
readCon2 = csvFileLines.read();
try
{
if (csvFileHeader && csvFileLines)
{
ttsbegin;
while(readCon1/*csvFileHeader.status() == IO_Status::Ok*/)
{
description = conPeek(readCon1,3);

ledgerJournalTable.clear();
ledgerJournalTable.initValue();
ledgerJournalTable.JournalNum = JournalTableData::newTable(ledgerJournalTable).nextJournalId();
ledgerJournalTable.journalType = LedgerJournalType::Daily;
ledgerJournalTable.JournalName = conPeek(readCon1,1);
ledgerJournalTable.Name = description;
ledgerJournalTable.initFromLedgerJournalName(ledgerJournalTable.JournalName);
ledgerJournalTable.insert();

readCon1 = csvFileHeader.read();
//numberSequenceTable = NumberSequenceTable::find(LedgerJournalName::find(ledgerJournalTable.JournalName).VoucherSeries);

//voucher = NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence).voucher();

while(readCon2/*csvFileLines.status() == IO_Status::Ok*/)
{
//assigning transaction date
strTransDate = conPeek(readCon2,2);
transDate = str2date(strTransDate, 213);

//assigning debit and credit
amountDebit = conPeek(readCon2,6);
amountCredit = conPeek(readCon2,7);

ledgerJournalTrans.clear();
ledgerJournalTrans.initValue();

ledgerJournalTrans.voucher = conPeek(readCon2,1); //voucher;
ledgerJournalTrans.JournalNum = ledgerJournalTable.JournalNum;
ledgerJournalTrans.Txt = conPeek(readCon2,5);
ledgerJournalTrans.transDate = transDate;
ledgerJournalTrans.AccountType = LedgerJournalACType::Ledger;
ledgerJournalTrans.AccountNum = conPeek(readCon2,4);

ledgerJournalTrans.AmountCurDebit = amountDebit;
ledgerJournalTrans.AmountCurCredit = amountCredit;
ledgerJournalTrans.Company = strLRTrim(conPeek(readCon2,13));
ledgerJournalTrans.CurrencyCode = "PHP";
ledgerJournalTrans.Dimension[1] = strLRTrim(conPeek(readCon2,9));
ledgerJournalTrans.Dimension[2] = strLRTrim(conPeek(readCon2,10));
ledgerJournalTrans.Dimension[3] = strLRTrim(conPeek(readCon2,11));
ledgerJournalTrans.insert();

readCon2 = csvFileLines.read();
}

ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable,NoYes::Yes);
ledgerJournalCheckPost.run();
}
ttscommit;

}
}
catch(Exception::Error)
{
info(strFmt("%1",Exception::Error));
}

return true;
}

Thank you

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Hi AXTECHGuy,

    To read or write file you need to assert FileIOPermissions, I can see Set permissionSet; declaration in your code, but cant see any usage of it.

    Please look at next msdn article https://msdn.microsoft.com/en-us/library/aa609747(v=ax.50).aspx it has an example how to use CodeAccessPermission::assertMultiple() with FileIoPermission to work with files.

  • Community Member Profile Picture
    on at

    Hi ievgen Miroshnikov,

    Tried this one ranjithdax.blogspot.com/.../request-for-permission-of-type.html

    put in my ATM_INTERFACE

    ImportfromATM but did not work, I really dont know what to do since I do technical part of AX and not as a programmer

  • Mea_ Profile Picture
    60,286 on at

    If you post new code we will try to hep you, however, it maybe a good idea to find a developer and ask him to do all work for you, because you need to have specific skill set and without it you probably won't do this mod without any issues.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 21

#2
dserp Profile Picture

dserp 4

#2
dekion Profile Picture

dekion 4

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans