adsenseheader

Thursday, October 31, 2019

Get Packing Slip Journal from Invoice Journal In Dynamics AX 365 for Operations

Hi,

The below code would help you in getting details of the Packing slip journal from the Invoice Journal.

static void getPackingSlip(Args _args)
{
    CustInvoiceJour     custInvoiceJour;
    SalesParmTable      salesParmTable;
    CustPackingSlipJour custPackingSlipJour;
    SalesParmSubLine    salesParmSubLine;
    SalesParmLine       salesParmLine;

    custInvoiceJour = CustInvoiceJour::findRecId(35637193385);
    select firstOnly salesParmTable
        where salesParmTable.ParmId == custInvoiceJour.ParmId
            && salesParmTable.Ordering == DocumentStatus::Invoice;

    //in case of multiple packing slip selected in invoice
    while select DocumentId from salesParmSubLine
            exists join salesParmLine
            where salesParmSubLine.LineRefRecId == salesParmLine.RecId
                && salesParmLine.ParmId          == salesParmTable.ParmId
                && salesParmLine.TableRefId      == salesParmTable.TableRefId
    {
        select firstOnly custPackingSlipJour
            where custPackingSlipJour.PackingSlipId == salesParmSubLine.DocumentId
                && custPackingSlipJour.SalesId == salesParmTable.SalesId;
        info(strFmt("%1-%2-%3-%4",custPackingSlipJour.DeliveryDate,custPackingSlipJour.PackingSlipId,salesParmTable.SalesId,custInvoiceJour.InvoiceId));
    }
   // info(strFmt("%1",salesParmTable.packingSlipId(salesParmTable)));
}

Thanks & Regards,
Pradeep

Tuesday, October 29, 2019

Add additional report designs on your Print management

HI,

If you are trying to find a way to populate your new report design on the print management form.

Please find the below steps.

1. Create a delegate of  your print management class "PrintMgmtDocType" method "getDefaultReportFormatDelegate"
2. Below code to add your new design

class QTQ_ProjInvcPrintMgmtDocTypeHandlers
{
    [SubscribesTo(classstr(PrintMgmtDocType), delegatestr(PrintMgmtDocType, getDefaultReportFormatDelegate))]
    public static void getDefaultReportFormatDelegate(PrintMgmtDocumentType _docType, EventHandlerResult _result)
    {
        switch (_docType)
        {
            case PrintMgmtDocumentType::SIProjInvoice:
            case PrintMgmtDocumentType::SIProjInvoiceWithBR:
if (curExt() == 'CRRO' || curext() == 'CRBG')
                {
                    _result.result(ssrsReportStr(QTQ_PSAPojInvoice, Report));
                }
else
                {
                    _result.result(ssrsReportStr(QTQ_PSAPojInvoice, Report_Standard));
                }
                break;
        }
    }

}

3. Now build the class, you can see your new report design under Fomsetup --> Print Management --> Report design











Thanks,
Pradeep


Wednesday, October 16, 2019

Make a text BOLD through expression in SSRS reports

Hi,

With the below steps you can concatenate Label and Field value and make only Label bold with the expressions as detailed below.

Step 1:

Go to Text box --> Expression










Step 2:

Go the expression properties (Double click on the Textbox expression) and select HTML


Tuesday, October 15, 2019

File upload and export data to excel

Hi,

Below code would be helpful to upload a file in Dynamics 365 for operations and take necessity actions on the data from the file.

Export the result to an excel file

class ReadAndExportData
{     
    NoYesId printOut;
    NoYesId deleteInventTransId;
    FileUploadTemporaryStorageResult fileVal;

    public NoYesId parmPrintOut(NoYesId _printOut = printOut)
    {
        printOut = _printOut;

        return printOut;
    }

    public NoYesId parmDeleteTransId(NoYesId _delete = deleteInventTransId)
    {
        deleteInventTransId = _delete;

        return deleteInventTransId;
    }

    public FileUploadTemporaryStorageResult parmgetFile(FileUploadTemporaryStorageResult _file = fileVal)
    {
        fileVal = _file;

        return fileVal;
    }

    public void run()
    {
        #define.filename("LotID.csv")
        AsciiStreamIo                                   file;
        Array                                           fileLines;
        FileUploadTemporaryStorageResult                fileUpload;
        PurchTable purchTable;
        PurchLine purchLine;
        InventTransOrigin inventTransOrigin;
        InventTrans inventTrans;
        boolean printDoc = false;

        CommaStreamIo io = CommaStreamIo::constructForWrite();
        const str filename = #filename;
        fileUpload = fileVal;

        if (this.parmPrintOut() && !this.parmDeleteTransId())
        {
            io.writeExp(["@AccountsPayable:PurchaseOrderId", "@SYS75853"]);

while select PurchId from purchTable
                where purchTable.PurchStatus == PurchStatus::Received
             
                where purchLine.PurchId == purchTable.PurchId
            {
                io.writeExp([purchLine.PurchId, purchLine.ItemId]);
            }

            // get stream
            System.IO.Stream stream = io.getStream();
            stream.Position = 0;

            // read stream
            System.IO.StreamReader reader = new  System.IO.StreamReader(Stream);
            str csvFileContent = reader.ReadToEnd();

            //send file to user for save
            File::SendStringAsFileToUser(csvFileContent,filename);
        }

        if (fileUpload != null)
        {
            file = AsciiStreamIo::constructForRead(fileUpload.openResult());
            if (file)
            {
                if (file.status())
                {
                    throw error("@SYS52680");
                }
                file.inFieldDelimiter(',');
                file.inRecordDelimiter('\r\n');
            }

            container record;
            io.writeExp(["@AccountsPayable:PurchaseOrderId", "@SYS75853"]);

            if (this.parmPrintOut() || this.parmDeleteTransId())
            {
                while (!file.status())
                {
                    record = file.read();
                    if (conLen(record))
                    {
                        inventTransOrigin = InventTransOrigin::findByInventTransId(conPeek(record,1));

                        if (inventTransOrigin.RecId)
                        {
                            if (this.parmPrintOut() && this.parmDeleteTransId())
                            {
                                printDoc = true;
                                io.writeExp([inventTransOrigin.InventTransId, inventTransOrigin.ItemId]);
                            }

                        }
                    }
                }
                if (printDoc)
                {
                    // get stream
                    System.IO.Stream stream = io.getStream();
                    stream.Position = 0;

                    // read stream
                    System.IO.StreamReader reader = new  System.IO.StreamReader(Stream);
                    str csvFileContent = reader.ReadToEnd();

                    //send file to user for save
                    File::SendStringAsFileToUser(csvFileContent,filename);
                }
            }
        }
    }

    public static void main(Args _args)
    {
        const str controlName = 'ItemFile';
        Dialog dialog = new Dialog("PurchaseOrderCorrection");
        DialogGroup dialogGroup;
        DialogField dialogPrintOut;
        DialogField dialogDelete;
        FormBuildControl            formBuildControl;
        ReadAndExportData postingIssue = new ReadAndExportData();

        dialogGroup = dialog.addGroup("PurchaseOrderCorrection");
        dialogGroup.columns(2);

        dialogPrintOut = dialog.addField(extendedTypeStr(NoYesId));
        dialogPrintOut.label("@SYS12608");

        dialogDelete   = dialog.addField(extendedTypeStr(NoYesId));
        dialogDelete.label("DeleteCorruptedPO");

        formBuildControl = dialog.formBuildDesign().control(dialogGroup.name());

        FileUploadBuild  dialogFileUpload = formBuildControl.addControlEx(classstr(FileUpload), controlName);
        dialogFileUpload.baseFileUploadStrategyClassName(classstr(FileUploadTemporaryStorageStrategy));
        dialogFileUpload.fileNameLabel("@SYS308842");

        if (dialog.run())
        {
            FileUpload fileUploadControl = dialog.formRun().control(dialog.formRun().controlId(controlName));
            FileUploadTemporaryStorageResult fileUploadResult = fileUploadControl.getFileUploadResult() as FileUploadTemporaryStorageResult;

            postingIssue.parmPrintOut(dialogPrintOut.value());
            postingIssue.parmDeleteTransId(dialogDelete.value());
            postingIssue.parmgetFile(fileUploadResult);
            postingIssue.run();
        }
    }

}

Get label value in other than the default language

Hi,

In dynamics365 for operations, you can see labels by default of en-us, when you use the tool "find labels" under Dynamics AX tab.

TO see labels in other languages

public static void main(Args _args)
{
    info(SysLabel::labelId2String(literalstr('@SYS1'), 'en-gb'));
}

Happy Daxing :)