Microsoft Dynamics AX development

To add a new datasource to the form InventOnHandItem, you have to follow these steps.

In my case I’ve added the (InventTable).GTIN to the form.

Add the table (in the example I’ve used the InventTable) to the form’s datasource

Aufnahme1

Modify the method modifyQuery in the class InventDimCtrl_Frm_OnHand:

  • add the new datasource to the method declaration and add a new variable for the new QueryBuildDataSource:

Aufnahme4

  • add the following code at the end of the method

 

Aufnahme2

  • it is important that the field you want to add to the InventOnHandItem is the “group by field”.

This is the result:

Aufnahme7

PurchFormLetter  purchFormLetter
ProductReceiptId productReceiptId;
PurchLine        purchLine;
PurchTable       purchTable = PurchTable::find('123456');
PurchQty         purchQty = 20;

while select purchLine
where purchLine.PurchId == purchTable.PurchId
&& purchLine.IsDeleted == NoYes::No
{
purchLine.PurchReceiveNow = purchQty;
purchLine.setInventReceiveNow();
purchLine.update();
}

purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
purchFormLetter.update(purchTable, productReceiptId, purchFormLetter.transDate(), PurchUpdate::ReceiveNow);
purchTable.reread();

PurchFormLetter purchFormLetter
PurchTable purchTable = PurchTable::find('123456');
PackingSlipId packingSlipId = 'PS_01';

purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
purchFormLetter.update(purchTable, packingSlipId);
purchTable.reread();

To keep table groups on the same page, the table group should look like this:

Aufnahme1

Then, select the group row and set the properties “KeepTogheter” to True.

Aufnahme2

Deploy the report.

 

Align image logo to the right

1) In the DP class find the width of the image:

Image img = new Image();
CompanyInfo companyInfo = CompanyInfo::find();
CompnayImage companyImage = CompnayImage::findByRecord(comapnyInfo);

img.setData(companyImage.Image);

salesPackingSlipHeaderTmp.LogoWidth = img.Width();

2) Add the image to the report:

2

3) Set the parameters to take the image from the dataset:

3

4) In Visual Studio set the Size property (of the image) to “Original size” (Right click on the image > Properies > Size)

5) Add the following expression in the “padding left” expression:

=CSTR(211-First(Fields!LogoWidth.value, “DataSetName”)) + “pt”

Where 211 is the maximum size (in pixel) of the image.

5
6) Deploy the report

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

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

Tag Cloud

Follow

Get every new post delivered to your Inbox.