Print additional report using SalesFormLetter framework

Print additional report using SalesFormLetter PrintExtraDocuments framework.

- SalesEditLines form:
ClassDeclaration
NoYes                   printReturnFormChoice;
- additional checkbox to
\Forms\SalesEditLines\Designs\Design\[Group:groupParameters]\[Tab:tabParameters]\[TabPage:tabPageParameters]\[Group:PrintGroup]\[Group:PrintCheckboxGroup]
public boolean modified()
{
    boolean ret;

    ret = super();
    
    printReturnFormChoice = printReturnForm.value();

    return ret;
}
- SalesEditLinesForm class
boolean PrintReturnForm()
{
    return false;
}
- SalesEditLinesForm_PackingSlip class
boolean printReturnForm()
{
    return true;
}
// change printExtraDocuments method to following look:
protected boolean printExtraDocuments()
{
    return this.printEntryCertificate_W() || this.PrintReturnForm();
}
- SalesFormLetterContract class:
// To classDeclaration
    NoYes           printReturnForm;
    str             printerSettingsReturnForm;

// Add both variables to ParmListSales macro

[DataMemberAttribute]
public NoYes parmPrintReturnForm(NoYes _printReturnForm = printReturnForm)
{
    printReturnForm = _printReturnForm;
    return printReturnForm;
}
[DataMemberAttribute]
public str parmPrinterSettingsReturnForm(str _printerSettingsReturnForm = printerSettingsReturnForm)
{
    printerSettingsReturnForm = _printerSettingsReturnForm;
    return printerSettingsReturnForm;
}
- SalesFormLetter class
public boolean  printReturnForm(boolean  _printReturnForm = salesFormLetterContract.parmPrintReturnForm())
{
    return salesFormLetterContract.parmPrintReturnForm(_printReturnForm);
}
public container printerSettingsReturnForm()
{
    return SysOperationHelper::base64Decode(salesFormLetterContract.parmPrinterSettingsReturnForm());
}
protected void  updatePrinterSettingsReturnForm(container  _printerSettings)
{
    salesFormLetterContract.parmPrinterSettingsReturnForm(SysOperationHelper::base64Encode(_printerSettings));
}
/// <summary>
/// Modifies the printer settings for return form by using the standard printer settings dialog box.
/// </summary>
/// <param name="_salesFormLetter">
/// The <c>SalesFormLetter</c> class where the printer settings for return form are being modified.
/// </param>
/// <returns>
/// true if the settings were modified; otherwise, false.
/// </returns>
static boolean callPrinterSettingsReturnForm(SalesFormLetter _salesFormLetter)
{
    SRSPrintDestinationSettings printSettings = new SRSPrintDestinationSettings(_salesFormLetter.printerSettingsReturnForm());
    boolean ok = SrsReportRunUtil::showSettingsDialog(printSettings);

    _salesFormLetter.updatePrinterSettingsReturnForm(printSettings.pack());

    return ok;
}
public static void SLNCheckClientOutput(XppPrePostArgs _args)
{
    SalesFormLetter SalesFormLetter = _args.getThis();
    boolean         ok              = _args.getReturnValue();
    boolean         showError       = _args.getArg('_showError');
    
    if (SalesFormLetter.printReturnForm())
    {
        if (FormLetter::isClientOutput(SalesFormLetter.printerSettingsReturnForm()))
        {
            ok = showError ? checkFailed("@SLN6553") : false;
            _args.setReturnValue(ok);
        }
    }
}
// add following code to checkClientOutputPrintManagement method
    if (this.printReturnForm())
    {
        if (FormLetter::isClientOutput(this.printerSettingsReturnForm()))
        {
            ok = _showError ? checkFailed("@SLN6553") : false;
            printerSetupError = true;
        }
    }
Add post event handler at \Classes\SalesFormLetter\checkClientOutput to \Classes\SalesFormLetter\SLNcheckClientOutput
- SalesEditLines form:

// method run, after line 30
        printReturnFormChoice       = (salesFormLetter.printReturnForm());
        printReturnForm.value         (printReturnFormChoice);

// Data Sources\SalesParmTable\Methods\active
    if (salesEditLinesForm.printReturnForm())
    {
        ButtonReturnForm.visible(true);
        printReturnForm.visible(true);
        printReturnForm.allowEdit(true);
        printReturnForm.skip(false);
        printReturnForm.value(printReturnFormChoice);
    }
    else
    {
        ButtonReturnForm.visible(false);
        printReturnForm.visible(false);
        printReturnForm.allowEdit(false);
        printReturnForm.skip(true);
        printReturnForm.value(false);
        printReturnFormChoice = false;
    }

// \Forms\SalesEditLines\Methods\closeOk after salesFormLetter.initParameters
salesFormLetter.printReturnForm(printReturnFormChoice); 
Duplicate button:
\Forms\SalesEditLines\Designs\Design\[Group:groupParameters]\[ButtonGroup:GroupParametersButtonGroup]\[MenuButton:PrinterSettings]\Button:ButtonShippingStat
and change related properties such as Text, ConfigurationJey and Name to ButtonReturnForm
void clicked()
{
    super();
    SalesFormLetter::ŅallPrinterSettingsReturnForm(salesFormLetter);
}
- SalesPackingSlipJournalPrint class printJournal
// ClassDeclaration
    NoYes               printReturnForm;
    container           printerSettingsReturnForm;
// add variables to CurrentList macro
public container parmPrinterSettingsReturnForm(container _printerSettingsReturnForm = printerSettingsReturnForm)
{
    printerSettingsReturnForm = _printerSettingsReturnForm;
    return printerSettingsReturnForm;
}
public NoYes parmPrintReturnForm(NoYes _printReturnForm = printReturnForm)
{
    printReturnForm = _printReturnForm;
    return _printReturnForm;
}
public static void printReturnForm(XppPrePostArgs _args)
{
    Args                parameters = new Args();
    MenuFunction        returnFormMenu;

    SalesPackingSlipJournalPrint    journalPrint    = _args.getThis();
    Set                             journalList     = _args.getArg('_journalList');
    SetEnumerator                   se              = journalList.getEnumerator();
    CustPackingSlipJour             journal;

    if (journalList.elements())
    {
        if (journalPrint.parmPrintReturnForm() && !journalPrint.parmProforma())
        {
            se.reset();
            while (se.moveNext())
            {
                journal = se.current();
                returnFormMenu = new MenuFunction(menuitemOutputStr(ReturnForm), MenuItemType::Output);
                parameters.caller(journalPrint);
                parameters.record(journal);

                returnFormMenu.run(parameters);
            }
        }
    }
}
public static void SLNNewFromFormletterContract(XppPrePostArgs _args)
{
    SalesPackingSlipJournalPrint        salesPackingSlipJournalPrint        = _args.getReturnValue();
    SalesFormLetterPackingSlipContract  salesFormLetterPackingSlipContract  = _args.getArg('_salesFormLetterPackingSlipContract');

    salesPackingSlipJournalPrint.parmPrinterSettingsReturnForm(SysOperationHelper::base64Decode(salesFormLetterPackingSlipContract.parmPrinterSettingsReturnForm()));
    salesPackingSlipJournalPrint.parmPrintReturnForm(salesFormLetterPackingSlipContract.parmPrintReturnForm());
    
    _args.setReturnValue(salesPackingSlipJournalPrint);
}
Add post event handler at \Classes\SalesPackingSlipJournalPrint\printJournal to \Classes\SalesPackingSlipJournalPrint\printReturnForm
Add post event handler at \Classes\SalesPackingSlipJournalPrint\newFromFormletterContract to \Classes\SalesPackingSlipJournalPrint\SLNnewFromFormletterContract

Example of prePromptModifyContract method at report controller:
/// <summary>
///    Modifies the report query and parameters based on caller settings.
/// </summary>
protected void prePromptModifyContract()
{
    Common                          common;
    CustPackingSlipJour             journal;
    ReturnFormContract              contract;
    SalesPackingSlipJournalPrint    salesPackingSlipJournalPrint;
    
    contract    = this.parmReportContract().parmRdpContract() as ReturnFormContract;

    this.parmDialogCaption("@SLN6542");

    if (classIdGet(this.parmArgs().caller()) == classNum(SalesPackingSlipJournalPrint))
    {
        salesPackingSlipJournalPrint = this.parmArgs().caller() as SalesPackingSlipJournalPrint;
        this.parmReportContract().parmPrintSettings(new SRSPrintDestinationSettings(salesPackingSlipJournalPrint.parmPrinterSettingsReturnForm()));
    }

    if (this.parmArgs().record())
    {
        common = this.parmArgs().record();
    }
    if (common.TableId == tableNum(CustPackingSlipJour))
    {
        journal = common;
        contract.parmSalesId(journal.SalesId);
    }
    else
    {
        checkFailed(strFmt("@SYS26348"));
        return;
    }
}


 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units and "buy me a coffee" link.
Join us.

Blog Tags