Microsoft Dynamics AX development

Call two time the same report but with different design from controller class

Scenario: I have a report (MyReport) with two desing (DesignA and DesignB). The two designs are in the same report because the datasource is the the same and they are called from the same menu item.
The DesignA is always printed, but only in some cases I have to print the DesignB.

In the controller class, in the output method, I’ve added the following code:

outputMethod

 

Advertisements

Scenario: I have two textbox on the same line. Textbox A and Textbox B. Both have an hidden expression in order to hide the textbox if empty.

Aufnahme3

If the Textbox A is empty, maintains the white space in the layout.

Aufnahme4

The solution is to insert the two textbox in a rectangle.

Aufnahme5

In this way, the space of the textbox A is removed.

Aufnahme8

The entity DMFPriceDiscAdmTransEntity requires the field JournalNum.
I want to generate automatically this number.

In the class DmfPriceDiscAdmTransEntityClass I’ve added a new method:

Aufnahme1

If I start another “Copy data to target”, I hava already the JournalNum (and an existing Price journal) and the target records will be updated (if the journal is not posted).

In the method generatePriceDiscTableLink I’ve called the new method:

Aufnahme2

 

Scenario:
I have to create a dialog with SrsReportDataContractUIBuilder with:

  • a flag “MyFlag”
  • a button “MyButton”

When the flag is active, I have to disable the button.
When the flag is not active, I have to enable the button.

Create the UIBuilder class:

class MyUIBuilderClass extends SrsReportDataContractUIBuilder
{
    MyClassNameContract       contract;
    FormBuildButtonControl    myButton;
    DialogField               myFlag;
}

In the postBuild method, initialize the dialog with the controls:

Dialog                  dialogLocal;
Form                    form;
DialogGroup             dialogGroup;
FormBuildGroupControl   groupBuildControl;

dialogLocal = this.dialog();
contract = this.dataContractObject() as MyClassNameContract;
form = this.dialog().form();

myFlag = this.addDialogField(methodStr(MyClassNameContract, parmMyFlag), 
                             contract);

dialogGroup = dialogLocal.addGroup('My group name');
groupBuildControl = dialogLocal.formBuildDesign().control(
                    dialogGroup.formBuildGroup().id());
buttonBuildControl = groupBuildControl.addControl(FormControlType::Button, 
                     'My button name');

super();

myButton.text(literalStr("A text for my button"));

//if you want to add a method for the button
myButton.registerOverrideMethod(methodStr(FormButtonControl, clicked), 
         methodStr(MyUIBuilderClass, methodForTheButton), this);

myFlag = this.bindInfo().getDialogField(this.dataContractObject(), 
         methodStr(MyClassNameContract, parmMyFlag));
myFlag.value(true);
myFlag.registerOverrideMethod(methodStr(FormChecKBoxControl, modified), 
       methodStr(MyUIBuilderClass, enableDisableMyButton), this);

buttonBuildControl.enabled(!myFlag.value());

 

In the method enableDisableMyButton:

public boolean enableDisableMyButton(FormCheckBoxControl _checkBoxControl)
{
    int ctrlId          = dialog.formRun().controlId('My button name');
    FormControl control = dialog.formRun().control(ctrlId);

    control.enabled(!_checkBoxControl.checked());

    return true;
}

 

Insert the logic to bind the UIBuilder to the contract class, in the attributes:

[
     DataContractAttribute,
     SysOperationContractProcessingAttribute(
        classstr(ReturnAcknowledgmentAndDocUIBuilderWPC))
]

The “Generate mapping” regenerate the mapping from staging to target.

When we click on “Generate mapping” we have two possibility:

aufnahme1

Generate the mapping from scratch
It means that AX deletes and recreate the mapping. With this options all the (possible) manual modifications are deleted.

Generate the mapping from modifications
It means that AX adds the modifications to the existing mapping and the (possible) manual modifications are preserved. But, with this option we have a problem, if we have overwritten the method “getMappings()”.
AX creates duplicate mappings for those specified in this method.
For example, entity DMFProductEntity.

Method “getMappings” of the class (take into consideration the field AllocateMarkup):

aufnahme6

Here we have the mapping BEFORE the “Generate mapping from modifications”:
aufnahme2

Here we have the mapping AFTER  the “Generate mapping from modifications”:
aufnahme3The problem is that AX does not control if a  mapping already exists for the entity.

The method that duplicates the mappings is on the table DMFTargetXMLToEntityMap.generateMapping(). I’ve found a solution and added the following modification in order to control if the mapping already exists:

aufnahme4

In this way we haven’t anymore duplicates.

 

Scenario:
I want to mapping one field in the staging table with multiple fields on the target table.
In the image, the field EmploymentType is mapped with two fields on the target table.

(For the example I’ve used the Employee entity)

Aufnahme2.png

To do this, you have to add a mapping in the code. For example, view the class DMFEmployeeEntityClass, method getMapping:

Aufnahme3.png

In the example, the field DMFEmployeeTargetEntity.PersonnelNumer is mapped with the HcmWorker.PersonnelNumber and the RetailStaffTable.StaffId.

Compile and refresh the mapping.

 

Scenario:
I have a user that is associated to a custom role (TradeSalesClerk + other permissions/duties).

I’ve added the following permissions to the role:

  • SalesQuotationGenerate
  • SalesQuotationTableDetailsMaintain

but in the form of the customers (CustTableListPage + CustTable) the user does not see the button for the creation of a sales quotation (see picture below).

untitled

Solution:
In the permission “SalesQuotationTableDetailsMaintain”, the entry point “SalesCreateQuotation” has AccessLevel = read.
I’ve changed the AccessLevel to “Create”, and it resolves the problem!

The problem was caused due to the fact that the menu item SalesCreateQuotation used in the CustTableListPage form was defined as entry point in privilege SalesQuotationTableDetailsMaintain with entry mode “Read”, but on the CustTableListPage form the button had the property “OpenMode” set to “New”.

In this case the security framework “hides” the button as the user has only defined the “View” permission although “Create” is required to invoke the Button.

 

Tag Cloud