vendredi 3 juin 2011

How to pass parameter through SalesFormLetter Class

throughFor example, you want to pass parameter from SalesEditLines Form to SalesInvoice report, you need to pass through SalesFormLetter Class

Here is what you can do :

  in the method CloseOk of your SalesEditLines  Form, you get the value of a control
        salesFormLetter.Thy_ProformaId(Thy_ProformaIdTable_ProformaId.valueStr());

Here is the method  Thy_ProformaId in the SalesFormLetter Class

//<iba>
Thy_ProformaId thy_ProformaId(Thy_ProformaId _thy_ProformaId = thy_ProformaId)
{
    ;
    thy_ProformaId = _thy_ProformaId;
    return thy_ProformaId;
}
//</iba>
In the classDeclaration add  thy_ProformaId variable to the localMacro

 #LocalMACRO.CachedArgsList
        parmEnum,
        callerFormName,
        isProforma,
        formHasInterCompanyRefreshCacheMethod,
        parmSkipPrompt
    #ENDMACRO

You need also to initilize the variable in resetParmListCommonCS method like the other variable of localMacro

public void resetParmListCommonCS()
{
    ;
    salesTable          = null;
    editLinesChanged    = false;
    reArrangeNow        = false;
    initAllowEmptyTable = false;
    allowEmptyTable     = false;
    enableUpdateNow     = false;
    lockSalesUpdate     = false;
    createFromLines     = false;
    createFromHistory   = false;
    showQueryForm       = false;
    multiForm           = false;
    transDate           = dateNull();
    giroType            = 0;
    defaultGiroType     = NoYes::No;

    //<iba>
    thy_proformaId      = '';
    //</iba>
}

Finally in the init method ofthe salesInvoice report, get the value of thy_ProformaId method of SalesFormLetter Class in a variable declared in classDeclaration and use it in a display method to use it in your report

if (classidget(element.args().caller()) == classnum(SalesFormLetter_Invoice))
    {
        salesFormLetter = element.args().caller();

        if(! SalesformLetter.proforma()
           && ( SalesformLetter.documentStatus() == DocumentStatus::Invoice )
           && ( SalesformLetter.thy_ProformaId()))
        {
            thy_proformaId = salesFormLetter.thy_ProformaId();
            thy_ProformaId0.visible(true);
            thy_ProformaId0.showLabel(true);
        }
        else
        {
            thy_ProformaId0.showLabel(false);
            thy_ProformaId0.visible(false);
        }
    }

Happy Daxing ! 

Aucun commentaire:

Enregistrer un commentaire