Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Thursday, December 29, 2022

Adding filter to tablix using in """ XYZ""","""LMN""" in SSRS

 Hello,


When we add ranges values to tablix filters will auto updates the values to """.


This can be fixed by 

=CStr("03. Lines,04. Lines Total").Split(",")


Regards,

Wednesday, September 28, 2022

Display method in D365

 /// <summary>

/// <MAI 09282022>

/// FDD details

/// </MAI>

/// </summary>

[ExtensionOf(tablestr(PurchLine))]

public final class PurchLine_XXYYX_Extension

{

    public display NoYes isXYZ()

    {

        return InventTable::find(this.ItemId).XYZ;

    }

}

NOTE: In the coming days extensions will be recessive, so avoid static the display method.

Wednesday, June 22, 2022

Orig() in AX / D365

 Hi,


Orig() is to get the last saved values. This method is used to compare the new values with last saved values.


if(purchTable.orig().DlvTerm != purchTable.DlvTerm)
    {
        //element.updateDlvTerm();
        //Your custom code
}


Regards,

Tuesday, June 21, 2022

Overlayer/Override a methods in D365

 Hi,


Overlayer of standard code to execute your methods is not possible literally, whereas there are several other ways to override.

Procedure.

1. Class to register the override you created.

2. Call the registered call on the eventHander.

Registering Override method.

/// <summary>
/// Custom class created by MAI on 6/21/2022
/// to register the <c>Purchtable</c> form.
/// </summary>
public class PurchTableEventHandler
{
    /// <summary>
    /// Post event handler for <c>Purchtable</c> Initialized event.
    /// </summary>
    /// <param name=“_sender”></param>
    /// <param name=“_e”></param>
    [FormDataSourceEventHandler(formDataSourceStr(PurchTable, PurchTable), FormDataSourceEventType::Initialized)]
    public static void PurchTable_OnInitialized(FormDataSource _sender, FormDataSourceEventArgs _e)
    {
        var overrides = PurchTableFormExtensionOverrides::construct();
 
        _sender.object(fieldNum(PurchTable, CashDisc)).registerOverrideMethod(methodStr(FormDataObject, validate),
            methodStr(PurchTableFormExtensionOverrides, CashDisc_OnValidate), overrides);
    }
}

Calling the Registered methods.

/// <summary>
/// Calling override classes <c>PurchTable</c> data source field methods.
/// </summary>
public class PurchTableFormExtensionOverrides
{
    protected void new()
    {
    }
 
    /// <summary>
    /// Constructs a new instance of <c>PurchTableFormExtensionOverrides</c> .
    /// </summary>
    /// <returns>
    /// new of  <c>PurchTableFormExtensionOverrides</c> class.
    /// </returns>
    public static PurchTableFormExtensionOverrides construct()
    {
        return new PurchTableFormExtensionOverrides();
    }
 
 
    /// <summary>
    /// Checks whether <c>CashDisc</c> is valid.
    /// </summary>
    /// <param name = "_targetField"> The <c>FormDataObject</c> where the Validate is triggered.</param>
    public boolean CashDisc_OnValidate(FormDataObject _targetField)
    {

        boolean ret = _targetField.validate();
 
        if (ret)
        {
            //Your code
        }
 
        return ret;
    }
}

Regards,



Calling custom method of other layer objects created in form level in D365

 Hi,


Using an event handler, we cannot call the custom methods created in another later / model/ ISV object. 

On calling formRun.CreateDeliveryNote()  throws the error ‘FormRun doesn't have the method CreateDeliveryNote.

FormDataSource purchTable_ds = sender.datasource();
FormRun formRun = purchTable_ds.formRun();
formRun.CreateDeliveryNote() ;

Conclusion is to use only COC not eventhandler

[ExtensionOf(formDataFieldStr(PurchTable, PurchTable, DeliveryDate))]
final class PurchTableDeliveryDateField_Extension
{
    public void modified()
    {
         next modified();
         element.CreateDeliveryNote(); // Custom method from Other Later / Model 
    }
}


Regards

Sunday, June 19, 2022

Exdends property of D365

Hi,


To know the ISV objects implications.


[ExtensionOf(classStr(ClassToExtend))] - class

[ExtensionOf(formstr(FormToExtend))] - Forms and its methods

[ExtensionOf(formdatasourcestr(FormToExtend, DataSource1))] - Form Datasource and its methods

[ExtensionOf(formdatafieldstr(FormToExtend, DataSource1, Field1))] - Form Datasource fileds and its methods

[ExtensionOf(formControlStr(FormToExtend, Button1))] - Form Object and its methods

[ExtensionOf(tablestr(TableToExtend))] - Table methods

[ExtensionOf(tableStr(DataEntityToExtend))] - Entity methods


Regards,

Thursday, June 16, 2022

Count the no of rows updated using update_recordset in AX 2012/D365

Hi,

static void Job560(Args _args)
{
    PurchLine       purchLine;
    PurchTable      purchTable;
 
    update_recordset purchLine
        setting
            CustomerRef = "CUST_0012"
        join PurchTable
            where PurchTable.PurchId == "PO-000368"
            && PurchTable.PurchId == purchLine.PurchId
             && purchLine.CustomerRef == "";
    info(strFmt("PurchTable = %1, PurchLine = %2 records updated",purchTable.RowCount(),purchline.RowCount()));
}


Regards,

Thursday, May 19, 2022

Get current record or select datasource of formDataSource extension of a form in D365

  Hi,

[ExtensionOf(formDataSourceStr(SalesTable, SalesLine))]

final class Dpay_SalesTable_SalesLine_FDS_Extension

{

        //init of SalesLineDS of SalesTable form

void initValue()

{

FormDataSource     formDataSource = this;


SalesLine    salesLine = formDataSource.cursor();

                

                //your logic        


next initValue();


//Your logic

}

}


Regards,


How to select the datasource of a form when you are the extension of formDatasource of another table in D365

 Hi,

[ExtensionOf(formDataSourceStr(SalesTable, SalesLine))]

final class Dpay_SalesTable_SalesLine_FDS_Extension

{

        //init of SalesLineDS of SalesTable form

void initValue()

{

FormDataSource     formDataSource = this;


SalesLine    salesLine = formDataSource.cursor();

SalesTable  salesTable = formDataSource .formRun().dataSource( formDataSourceStr( SalesTable, SalesTable)).cursor();

                

                //your logic        


next initValue();


//Your logic

}

}


Regards,



Sunday, May 15, 2022

renamePrimaryKey() in D365

 Hi,


In this article, we will discuss renamePrimaryKey(). 

In the operation of changing the value any of the primary key values in the system like CustId, VendId, PurchID, PersonnelNumberId, ProjID, etc needs to reflect its supporting relationed child tables.

This can be manually achievable by renaming on record Info of the particular form.

Here my case is to do the same through code for a large list of values.


CustTable CustTable;

ttsBegin;

select firstOnly CustTable where CustTable.AccountNum == "00445";

if (CustTable)

{

CustTable.AccountNum = "CUST-00445";

CustTable.renamePrimaryKey();

}

ttsCommit;

}


On running the above snippet, all the transactions got updated with the new values.

Regards,



Playing with displayOption in D365

Hi,

Change the fonts, colors and other display-related information of the grid or forms can be achieved here.


Override the displayOption() from the formDatasource, if there is multiple db please select the parent DB 


public void displayOption(Common _record, FormRowDisplayOption _options)

{

    HcmWorker   hcmWorkerLoc = _record as HcmWorker;

 

    super(_record, _options);

 

    _options.fontBold(true); // to make the text bold

    _options.fontItalic(true); // to make text Italic

    _options.fontUnderline(true); // to Underline the text by default

    _options.backColor(WinAPI::RGB2int(255,0,127 )); // to change the background color of the glid

    _options.textColor(WinAPI::RGB2int(255,255,0)); // to change the text color of the glid

 

}

 Regards,


Tuesday, April 12, 2022

Iterate the Error/ info log using Enumerator in AX 2012/ D365 F&O

Hi,


 SysInfologEnumerator sysInfologEnumerator;

    SysInfologMessageStruct sysInfologMessageStruct;

    Exception exception;

    checkFailed("Warning Msg");

    error("Error MSG");

    info("Info Msg");

    sysInfologEnumerator = SysInfologEnumerator::newData(infolog.cut());

    

    while (sysInfologEnumerator.moveNext())

    {

    sysInfologMessageStruct = new SysInfologMessageStruct(sysInfologEnumerator.currentMessage());

    exception = sysInfologEnumerator.currentException();

    info(strFmt("Msg type: %1; Message: %2",

        exception,

        sysInfologMessageStruct.message()));

    } 


Regards,

MAI

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...