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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Problem in batch IO job

(0) ShareShare
ReportReport
Posted on by

Hi!

Here is my code:

void createCSVCurrencyFile()
{
      Commaio file;
    container line;
    ExchRates exRates;
    Str filename;
    Str todayString;
     FileIOPermission       readPermission;
    ;

    todayString = date2Str
        (today(),
        321,
        DateDay::Digits2,
        DateSeparator::Hyphen, 
        DateMonth::Digits2,
        DateSeparator::Hyphen, 
        DateYear::Digits4
        );

    filename ="\\\\servername\\AX\\Currencies\\Rates_"+todayString+"_cmpy.csv";

    readPermission = new FileIOPermission(filename, "w");

    readPermission.assert();

    file =new Commaio(filename , "w");
    file.outFieldDelimiter(';');

    if( !file || file.status() != IO_Status::Ok)
    {
        //throw error("File Cannot be opened");
    }

    while select exRates
           where exRates.DataAreaId == 'cmp'
           && exRates.FromDate == today()
    {
        line = [
        exRates.CurrencyCode,
        //exRates.FromDate,
        date2Str
        (exRates.FromDate,
        321,
        DateDay::Digits2,
        DateSeparator::Hyphen, 
        DateMonth::Digits2,
        DateSeparator::Hyphen, 
        DateYear::Digits4
        ),
        exRates.Exchrate];
        file.writeExp(line);

    }
    CodeAccessPermission::revertAssert();
}


The job received the following error: CommaIo object not initialized.

any suggestion? :)

*This post is locked for comments

I have the same question (0)
  • XB Profile Picture
    1,875 on at

    Exist path? do you have access to the path?

  • Community Member Profile Picture
    on at

    Hi!

    Yes the path is valid. The same code with simple job works perfectly.

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    If you run it in a job, it runs on client under your account.

    If you run it in a batch, it runs on AOS (usually a completely different machine) and under the AOS service account (usually a completely different account that yours).

    That's why testing the code in a job doesn't say much about how it will behave in batch.

    First of all, check if the AOS service account has permissions to write to the file.

  • Suggested answer
    Community Member Profile Picture
    on at

    I guess your AOS service account does not have access to the folder. Please check if the AOS service account has read access to the directory.

  • Community Member Profile Picture
    on at

    Thanks for all the responses!

    For the folder the permission is set to "Everyone" with write and modify.

    Isn't is enough?

  • Verified answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Since you are using a network share by telling it from the UNC path, you need to provide access in 2 places. Both in the Security tab, and on the Sharing tabs' permissions as well. If you only have one of them provided, that is the cause of your problem why it does not work.

  • Suggested answer
    Community Member Profile Picture
    on at

    Thank you, the Sharing tab was the missing step :)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans