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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Want to import csv file using code. Getting exception error.

(0) ShareShare
ReportReport
Posted on by 518

Hello all,

www.tech.alirazazaidi.com/.../

with reference to above post I have written the code but I am getting error that is in screenshot attached.

I am using runbase batch for the file selection and getting the file also.

The code I have written is

public void importCsvFile(Args _args)
{
    #File
    CommaTextIo             csvFile;
    Name FirstName;
    Name LastName;
    StudentInfo  studentInfo;
    //FilenameOpen        filenameOpen; //= “c:\\StudentInfo.csv”;//To assign file name
    Container           record;
    boolean first = true;
    ;
  
    csvFile = new CommaTextIo(filenameOpen, #IO_Read);  // csvFile is getting null value here in this par and the filenameOpen is having the file name.
    if (! csvFile || csvFile.status() != IO_Status::Ok)
    {
        throw error("@SYS19358");      
    }
    while (csvFile.status() == IO_Status::Ok)
    {
        record = csvFile.read();// To read file
        if (record)
        {
            if (first)  //To skip header
            {
                first = false;
            }
            else
            {
                FirstName = conpeek(record, 1);//To peek record
                LastName  = conpeek(record, 2);
                _StudentInfo.FirstName =FirstName;
                _StudentInfo.LastName  =LastName;
                _StudentInfo.insert();
            }
        }
    }
}

error-csv.png

How can I read the csv file or what is the mistake in this part of code.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Sukrut Parab Profile Picture
    71,735 Moderator on at

    As per error suggest you have to assert file IO permissions .  Refer below link

    community.dynamics.com/.../codeaccesspermission-problem

  • Siddhant Singh Profile Picture
    518 on at

    Hi Sukrut,

    fileIoPermission = new FileIoPermission(filenameOpen, 'r');

    I have added the above line of code but still the error is the same.

  • Suggested answer
    Heinz Schweda Profile Picture
    1,367 on at

    Hi, since this is a RunBaseBatch class, the code may be executed on the server side. Is the specified file name also accessible from the AOS server?

    Regards Heinz

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
Basit Profile Picture

Basit 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans