Dynamics AX Blog - Posts from 2017

These posts are machine-translated.
Currently, only posts from »2017« are displayed

Call SSRS-Report through code

A common requirement is that a report / report should be printed automatically at a certain point in time.

It is usually important to be able to give certain parameters to the report to be printed, and depending on how the report is structured on the development side this can be more or less complicated.

The following code calls a relatively simple Dataprovider-based report:

TutorialMyReportDataContract dataContract;
SrsReportDataContract srsReportDataContract;

controller = new SrsReportRunController();
controller.parmReportName(ssrsReportStr(TutorialMyReport, MyDesign)); 
controller.parmShowDialog(false);    
controller.parmLoadFromSysLastValue(false);  

srsReportDataContract =
controller.parmReportContract();

dataContract = srsReportDataContract.parmRdpContract();

dataContract.parmSalesId("S1000"); 

The next example calls the standard report Transactions (Customer Accounts > Reports > Transactions > Customer). The special feature of this report is that it uses a query within the data provider. To access these was the challenge:


 
 
 

Release Product

You can use the following line code to release a product in another company:

EcoResProductReleaseSessionManager ecoResProductReleaseSessionManager;
    
ecoResProductReleaseSessionManager = 
EcoResProductReleaseSessionManager::newReleaseSession();

ecoResProductReleaseSessionManager.addProduct(52565549190);
ecoResProductReleaseSessionManager.addLegalEntityForAllProducts(
CompanyInfo::findDataArea('USP2').RecId);

if( !ecoResProductReleaseSessionManager.execute())
{
    error("An error occured");
}

 
 
 

SysOperation-Framework: Lock field in dialog

If you have to lock a dialog field within a SysOperation-framework, which is integrated via a parm method, you can use code like the following (in UIBuilder).

public void postBuild()
{
    DialogField df_SalesId;

    super();

    df_salesId =
    this.bindInfo().getDialogField(
        this.dataContractObject(),
        methodStr(DEV_SalesUpdateDatacontract, parmSalesId));

    if(df_salesId)
    {
        df_salesId.allowEdit(false);
        df_salesId.skip(true);
    }
}

 
 
 

Use conView to display the contents of a container

ConViewYou can use conView() to display the contents of a container.

static void conViewExample(Args _args)
{
    container con;
   
    con = conIns(con,
                 conLen(con)+1, ["Mazda", 2]);
    con = conIns(con,
                 conLen(con)+1, ["Volkswagen", 1]);
    con = conIns(con,
                 conLen(con)+1, ["Ferrari", 3]);
   
    conView(con);
}

 
 
 

Tip: Get length of an extended data type (EDT)

Sometimes you just need the length of an extended data type (EDT):

new SysDictType(extendedtypenum(costingversionid)).stringLen()

 
 
 

SysOperation-Framework: Change the properties of a dialog box depending on other dialog boxes

Consider the following scenario: In the dialog of a SysOperation construct, a field must be manipulated depending on other fields, for example, the AllowEdit property should be changed.

Dialog

In the following you will find the code for a DataContract and the corresponding UIBuilder, in which the corresponding program logic is to be installed.

Here, depending on the selection in the Module field, you can either activate the Customer account field or the Vendor account field.

 

DataContract

[DataContractAttribute, SysOperationContractProcessingAttribute(classStr(TutorialSysOperationUIBuilder))]
public class TutorialSysOperationDataContract
{
    ModuleCustVend moduleCustVend;
    CustAccount custAccount;
    VendAccount vendAccount;
}

 

[DataMemberAttribute, SysOperationControlVisibilityAttribute(true), SysOperationDisplayOrderAttribute('1')]
public ModuleCustVend parmModuleCustVend(ModuleCustVend _moduleCustVend = moduleCustVend)
{
    moduleCustVend = _moduleCustVend;

    return moduleCustVend;
}

 

[DataMemberAttribute, SysOperationControlVisibilityAttribute(true), SysOperationDisplayOrderAttribute('2')]
public CustAccount parmCustAccount(CustAccount _custAccount = custAccount)
{
    custAccount = _custAccount;

    return custAccount;
}

 

[DataMemberAttribute, SysOperationControlVisibilityAttribute(true), SysOperationDisplayOrderAttribute('3')]
public VendAccount parmVendAccount(VendAccount _vendAccount = vendAccount)
{
    vendAccount = _vendAccount;

    return vendAccount;
}

 

UIBuilder

public class TutorialSysOperationUIBuilder extends SysOperationAutomaticUIBuilder
{
    DialogField df_ModuleCustVend;
    DialogField df_CustAccount;
    DialogField df_VendAccount;
}

The methods generated by the framework are made accessible in the method build().

This is the first time the modifyDialogFields() method is called, so that the property of the desired field is changed immediately, when the dialog is opened.

public void build()
{
    super();

    df_ModuleCustVend = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(TutorialSysOperationDataContract, parmModuleCustVend));
    df_CustAccount = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(TutorialSysOperationDataContract, parmCustAccount));
    df_VendAccount = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(TutorialSysOperationDataContract, parmVendAccount));

    this.modifyDialogFields();
}

In the postRun() method, the modify() method of the module field is overridden.

public void postRun()
{
    super();

    // Override modified method
    df_ModuleCustVend.registerOverrideMethod(methodStr(FormComboBoxControl, modified),
                                             methodStr(TutorialSysOperationUIBuilder, moduleCustVend_modified),
                                             this);
}

In this overridden method, we call the modifyDialogFields() method. Here, it is important that the method obtain the correct parameter profile and return the expected AX data type.

private boolean moduleCustVend_modified(FormComboBoxControl _control)
{
    this.modifyDialogFields();

    return _control.modified();
}

The "magic" goes through the modifyDialogFields() method. The fields are enabled or disabled, depending on the value selected in the module field.

private void modifyDialogFields()
{
    df_CustAccount.allowEdit(df_ModuleCustVend.value() == ModuleCustVend::Cust);
    df_VendAccount.allowEdit(df_ModuleCustVend.value() == ModuleCustVend::Vend);
}

Of course, many other properties of dialog boxes can be changed dynamically in the same way.


 
 
 

Tip: Determine the length of a table field

Sometimes you just need the length of a field of a table:

new SysDictType(SysDictField::findFieldByName(tableStr(SalesTable), identifierStr(SalesId)).typeId()).stringLen();

 
 
Pages 1 2 » 

 

 
 
 
Posts of the actual month
April 2017
MoTuWeThFrSaSu
 12
3456789
10111213141516
17181920212223
24252627282930
 
© 2006-2025 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.