Export data to excel file

To export data to an excel file, we can use the SysExcelWorksheetHelper.
Here an example:

static void exportExcelFile(Args _args)
{
    SysExcelApplication     xlsApplication;
    SysExcelWorkBooks       xlsWorkBookCollection;
    SysExcelWorkBook        xlsWorkBook;
    SysExcelWorkSheets      xlsWorkSheetCollection;
    SysExcelWorkSheet       xlsWorkSheet;
    SysExcelWorksheetHelper worksheetHelper;
    SysExcelHelper          sysExcelHelper;
    VendRFQJour             vendRFQJour;
    int                     row = 1;
    str                     fileName;
    str                     worksheetName;
    Date                    deliveryDate;

    fileName    = "Path\\Test.xlsx";

    vendRFQJour = VendRFQJour::find("000103");

    worksheetName = "Worksheet name";
    sysExcelHelper = SysExcelHelper::construct();
    sysExcelHelper.initialize();
    xlsWorkSheet = sysExcelHelper.addWorksheet(worksheetName);

    worksheetHelper = SysExcelWorksheetHelper::construct(xlsWorkSheet);

    worksheetHelper.addColumn(1, 'RFQ Id', Types::String);
    worksheetHelper.addColumn(2, 'Delivery date', Types::Date);

    worksheetHelper.setCellValue(1, row, 'RFQId');
    worksheetHelper.setCellValue(2, row, 'DeliveryDate');
    row++;

    worksheetHelper.setCellValue(1, row, vendRFQJour.RFQId);
    worksheetHelper.setCellValue(2, row, vendRFQJour.DeliveryDate);

    if(WinApi::fileExists(fileName))
        WinApi::deleteFile(fileName);

    sysExcelHelper.save(filename);
    sysExcelHelper.close();

    info(strFmt("Creato file: %1", fileName));
}

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;
}

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

Use HTML in SSRS reports

Create a string that contains HTML code, for example:

(TableName).(MyFieldName) = ‘<span style=”font-weight:bold”>’ + custTable.AccountNum + ‘</span>’;

MyFieldName is the name of the field on the tmp table for the report’s  dataset.

Open the layout in Visual Studio. In the report add a textbox and add to the textbox the MyFieldName field.

Right-Click on the placeholder in the textbox, and then click on “Placeholder properties”.

Aufnahme8

Select “HTML – Interpreter HTML tags as styles

 

Item description initialization

The field  “Text”, in the Sales order line details, is initialized depend on some parameters.

Capture

The parameters to set for the initialization are the following:

Accounts receivable > Setup > Forms > Form setup > General

Capture1

  1. Include both name and description = Yes: initialize the field with both the name (product name or search name if product name does not exist) and the description inserted in the EcoResProductTranslation
  2. Include both name and description = No: initialize the field only with the description inserted in the EcoResProductTranslation
  3. External item description = Append: merge the content of the field “Text”, with the External item description of the item
  4. External item description = Overwrite: overwrite the content of the field “Text” with the External item description of the item

You can find product name and description here:

Capture2

And the external item description here:

Capture3

SSRS Extra white pages

In the report properties, depend on the “Paper size”, Visual Studio sets automatically the width of the page.

We must consider left and right margins too.

Capture

The space that we can use is:

Paper width – left margin – right margin

In our case:

8,27 – 0,7 – 0 = 7,57 in

The body width does not be greater than this size.  To control the body size:

Right click on the body layout  > Properties:

Capture1

If the body size is greater than the paper size (with margins),  the system adds extra white pages.