Microsoft Dynamics AX development

Archive for March, 2015

Contact persons created with double address

During the import of the contact person, an additional address is always created.
If, in the file, there isn’t an address, the DIEF creates an empty address.

To avoid the problem, we must to insert an additional if clause in the DMFContactPersonEntityClass, method GeneratePostalAddress:

public container GeneratePostalAddress(boolean _stagingToTarget = true)
{
    container res;

    if (_stagingToTarget && entity.Address) //additional if
        res = DMFLogisticsAddressHelper::GeneratePostalAddressGlobal(entity, target, party, partyRecId,this.getRoleSeparator(), true, _stagingToTarget);

    if (_stagingToTarget)
    {
        res = conNull();
    }

    return res;
}
Advertisements

Print logo depend on print destination

Goal: print the logo only if the print destination is the printer

First of all we need a parameter, and we declare it in the contract class as follow:

[DataMemberAttribute('printLogo')]
public boolean parmPrintLogo(UsePrintMgmt _printLogo = printLogo)
{
    printLogo = _printLogo;
    return printLogo;
}

Then, we must to modify the code of the report controller. The controller must extend the SrsPrintMgmtFormLetterController or a subclass of this.

The method to override is: SrsPrintMgmtController.outputReport()
This method executes the report for the print management setting that is currently loaded.

In this way, for every record in the print management, we control the print destination, and consequently we set the parameter for the logo visibility.

protected void outputReport()
{
    SalesConfirmContract salesConfirmContract = contract as SalesConfirmContract;

    switch (formLetterReport.getCurrentPrintSetting().parmPrintJobSettings().printMediumType())
    {
        case SRSPrintMediumType::Printer : salesConfirmContract.parmPrintLogo(NoYes::No);
        break;

        default : salesConfirmContract.parmPrintLogo(NoYes::Yes);
        break;
    }

    super();
}

If the logo visibility, depend on the type of the PrintCopyOriginal, the code to use is the following:

protected void outputReport()
{
    SalesConfirmContract salesConfirmContract = contract as SalesConfirmContract;
    switch (formLetterReport.getCurrentPrintSetting().parmType())
    {
        case PrintMgmtDocInstanceType::Copy :
	salesConfirmContract.parmPrintLogo(NoYes::No);
        break;

        case PrintMgmtDocInstanceType::Original :
	salesConfirmContract.parmPrintLogo(NoYes::Yes);
        break;
    }
    super();
}

Now, we have to use the new parameter in the report layout. We found the parameter here:
parameter

Finally, insert the following code in the layout, in the “Visibility” property on the image.
Aufnahme2

Tag Cloud