Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا
Showing posts with label D365. Show all posts
Showing posts with label D365. Show all posts

Wednesday, July 7, 2021

Jobs to export CSV from D365

 Hi,


class DpayExportCSV

{        

     /// <summary>

    /// Runs the class with the specified arguments.

    /// </summary>

    /// <param name = "_args">The specified arguments.</param>

    public static void main(Args _args)

    {

        CommaStreamIo commaStreamIo = CommaStreamIo::constructForWrite();

        SalesTable       SalesTable;

        SalesLine       SalesLine;

        FilePath  tempDir = "C:\\Temp\\SalesTable.csv";

       // #define.filename(@'C:\Temp\SalesTable.csv')

        ;

 

        const str fileName = 'SalesTable.csv';

        commaStreamIo.writeExp(['Level', 'SalesId', 'CustAccount','DlvTerm']); // Header

        while select * from SalesTable

        {

            commaStreamIo.writeExp(['OH', SalesTable.SalesId, SalesTable.CustAccount,SalesTable.DlvTerm]);

            while select SalesLine where SalesLine.SalesId ==  SalesTable.SalesId

            {

                commaStreamIo.writeExp(['OL', SalesLine.ItemId, SalesLine.SalesQty, SalesLine.InventDimId]);

                //// You may further add your componbenets table below to this within this loop

            }

        }

        System.IO.Stream stream = commaStreamIo.getStream();

        stream.Position = 0;

 

        FileUploadTemporaryStorageResult result = File::SendFileToTempStore_GetResult(stream, fileName);

       // System.IO.File::Move(result.getFileName(),tempDir);

        System.IO.StreamReader sReader = new System.IO.StreamReader(result.openResult());


        // Set file contentn string

        str  fileContent = sReader.ReadToEnd();

        //System.IO.File::Move(fileContent,tempDir);

        // Save file

        File::SendStringAsFileToUser(fileContent, tempDir);

        

      //  File::SendFileToTempStore(stream,"\\C:\\Temp\\SalesTable.csv");

        info(result.getDownloadUrl());

        Message::Add(MessageSeverity::Informational, result.getDownloadUrl());

        

    }

}


Regards,

SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...