Wednesday, 2 March 2022

SrsPrintDestinationSettings form change for Email in d365 F&O

 [ExtensionOf(classStr(SrsPrintDestinationSettings))]

final class SrsPrintDestinationSettings_DDD_Extension

{

    public SysEmailId      DDDEmailId;

    public FileName        DDDFileName;


    #define.CurrentVersion(2)

    #localmacro.CurrentList

        DDDEmailId,

        DDDFileName

    #endmacro

    public str parmDDDEmailId(str _DDDEmailId = DDDEmailId)

    {

        DDDEmailId = _DDDEmailId;

        return DDDEmailId;

    }

    public str parmDDDFileName(str _DDDFileName = DDDFileName)

    {

        DDDFileName = _DDDFileName;

        return DDDFileName;

    }

    public SrsReportEMailDataContract parmEMailContract(SrsReportEMailDataContract _emailContract)

    {

        SrsReportEMailDataContract emailContract = next parmEMailContract(_emailContract);

        if (emailContract && this.parmDDDEmailId())

        {

            SysEmailTable           emailTable = SysEmailTable::find(this.parmDDDEmailId());

            SysEmailMessageTable    messageTable = SysEmailMessageTable::find(this.parmDDDEmailId(), SystemParameters::systemLanguageId());

            if (emailTable.SenderAddr)

            {

                emailContract.parmDDDFromAddress(emailTable.SenderAddr);

            }

            if (messageTable)

            {

                emailContract.parmBody(messageTable.Mail);

            }

        }

        return emailContract;

    }

    public str parmFileName(str _fileName)

    {

        FileName fileName = next parmFileName(_fileName);


        if (!_fileName && this.parmDDDFileName())

        {

            fileName = this.parmDDDFileName();

        }

          return fileName;

    }

    public container pack()

    {

        container packedClass = next pack();

        return SysPackExtensions::appendExtension(packedClass, classStr(SrsPrintDestinationSettings_DDD_Extension), this.DDDPack());

    }

    public boolean unpack(container _packedClass)

    {

        boolean result = next unpack(_packedClass);

        if (result)

        {

            container con = SysPackExtensions::findExtension(_packedClass, classStr(SrsPrintDestinationSettings_DDD_Extension));

            

            //Also unpack the extension

            if (!this.DDDUnpack(con))

            {

                result = false;

            }

        }

        return result;

    }

    private container DDDPack()

    {

        return [#CurrentVersion, #CurrentList];

    }

    private boolean DDDUnpack(container packedClass)

    {

        Integer version = RunBase::getVersion(packedClass);

        switch (version)

        {

            case #CurrentVersion:

                [version, #currentList] = packedClass;

                break;

            default:

                return false;

        }

        return true;

    }

}

-----------------------------------------------*****----------------------------------------

[ExtensionOf(formStr(SRSPrintDestinationSettingsForm))]
final class SRSPrintDestinationSettingsForm_DDD_Extension
{
    private SRSPrintDestinationSettings DDDPrintDestinationSettings()
    {
        if (!_printDestinationSettings)
        {
            if (this.args() != null)
            {
                _printDestinationSettings = this.args().caller() as SRSPrintDestinationSettings;
            }
        }

        return _printDestinationSettings;
    }

    public void closeOk()
    {

        SRSPrintDestinationSettings printSettings;

        printSettings = new SRSPrintDestinationSettings(this.DDDPrintDestinationSettings().pack());

        printSettings.parmDDDEmailId(DDDEmailId.text());
        printSettings.parmDDDFileName(DDDFileName.text());

        this.DDDPrintDestinationSettings().unpack(printSettings.pack());

        next closeOk();
    }

    public void init()
    {
        next init();

        container                   printSettingsPack;
        SRSPrintDestinationSettings printSettings;

        printSettingsPack = this.DDDPrintDestinationSettings().pack();
        printSettings = new SRSPrintDestinationSettings(printSettingsPack);

        DDDEmailId.text(printSettings.parmDDDEmailId());
        DDDFileName.text(printSettings.parmDDDfileName());
    }
}
----------------------------------*****-------------------

[ExtensionOf(classStr(SrsReportEMailDataContract))]
final class SrsReportEMailDataContract_DDD_Extension
{
    public str DDDFromAddress;

    public str parmDDDFromAddress(str _DDDFromAddress = DDDFromAddress)
    {
        DDDFromAddress = _DDDFromAddress;
        return DDDFromAddress;
    }
}


Add fields to SRSPrintDestinationSettingsForm.DDDExtension
1.DDDEmailId
2.DDDFileName

No comments:

Post a Comment

DefaultDimension in d365 FO X++

 Navigate to PurchTable methods you can find with DefaultDimension this.DefaultDimension = this.mergeDimension(this.getDefaultDimension(),th...