How to import only CSV files by browsing the local folders using x++ code

   AsciiStreamIo                                   file;

        Array                                           fileLines;

        FileUploadTemporaryStorageResult                fileUpload;

        fileUpload = File::GetFileFromUser() as FileUploadTemporaryStorageResult;

        file = AsciiStreamIo::constructForRead(fileUpload.openResult());

        if (file)

        {

            if (file.status())

            {

                throw error("@SYS52680");

            }

            file.inFieldDelimiter(',');

            file.inRecordDelimiter('\r\n');

        }

        container record;

        while (!file.status())

        {

            record = file.read();

            if (conLen(record))

            {

                info(strFmt("%1 - %2",conPeek(record,1),conPeek(record,2)));

            }

        }

        info("done");

Comments

Popular posts from this blog

How to Create a wizard in x++ d365

X++ code to CREATE AND POST A TRADE AGREEMENT IN MICROSOFT DYNAMICS 365 in D365 F & O

x++ code to submit and approve and reject the invent movement workflow in d365 F&O