Showing posts with label COC. Show all posts
Showing posts with label COC. Show all posts

Friday, October 1, 2021

How to use form global variables in Form DS/Form control extension class in D365fo using x++.

 One Table is declared in the form 'class declaration' method (Global). I want to access that table buffer in my form control extension class(COC). For achieving that I used the below code.

     [ExtensionOf(formControlStr(MyForm, MyControl))]

public final class MyFormMyControl_Extension { public boolean modified() { // FormCheckBoxControl control = any2Object(this) as FormCheckBoxControl; // FormRun control = tax.formRun(); FormRun FormRun = salesTable_ds.Formrun(); boolean ret; MyTable myTable = element.myTable;
            // My table buffer declared in "class declaration" method.(Global) ret = next modified(); myTable.parmmethod(this.value()); //element.enableSearch(); return ret; } }


Keep daxing!!

Wednesday, August 18, 2021

Get method is called from form or not in d365FO

Get method is called from form or not.


    If ( FormDataUtil::isFormDataSource(this)) { info('test'); } if (FormDataUtil::getFormDataSource(this)) { FormDataUtil::getFormDataSource(this).research(); FormDataUtil::getFormDataSource(this).findRecord(Table buffer); }


Keep Daxing!!

Monday, March 15, 2021

change view mode to edit mode of a form In D365Fo

How to change form view mode to edit mode in D365.


  • To subscribe to view/edit mode switching, use these events:
    • element.viewEditModeHelper().EditModeSwitching
    • element.viewEditModeHelper().EditModeSwitche
  • To query the current view/edit mode, use these events:
    • element.viewEditModeHelper().isInEditMode()
    • element.viewEditModeHelper().IsInViewMode()
  • To trigger view/edit mode switching, use these events:
    • element.viewEditModeHelper().setViewEditMode(ViewEditMode::Edit)

Keep Daxing!!

Monday, December 7, 2020

Adding Code in Standard Table using COC(Chain of command) in AX7/D365fo

 

Hi guys, Today we see how to Add Code in Standard Table using COC in AX7/D365fo.


Check the Below Example.

[ExtensionOf(tableStr(CustGroup))]
Final class CustGroup_Extension
{
    [SysClientCacheDataMethod(true)]
    display Name displayName()
    {
        return this.CustGroup + ' ' + this.PaymTermId;
    }

    void initValue()
    {
        // pre event
        next initValue();
        //Post event

        this.NoYes = NoYes::Yes;
    }

    public void modifiedField(FieldId _fieldId)
    {
        next modifiedField(_fieldId);

        switch (_fieldId)
        {
            case fieldnum(CustGroup, NoYes):
                this.PriceIncludeSalesTax = this.NoYes == NoYes::Yes ? 
                                                NoYes::Yes : NoYes::no;
                break;
        }
    }

    public boolean validateWrite()
    {
        boolean ret = next validateWrite();

        if(!this.TaxGroupId)
        {
            ret = checkFailed('Tax group is mandatory');
        }

        return ret;
    }

    public boolean validateField(FieldId _fieldIdToCheck)
    {
        boolean ret;

        ret = next validateField(_fieldIdToCheck);

        switch (_fieldIdToCheck)
        {
            case fieldnum(CustGroup, Name):
                if (this.NoYes == NoYes::Yes)
                {
                    if(this.Name =="")
                    {
                        ret = ret && checkFailed('when check box is yes
                                this field is mandatory');
                    }
                }
        }

        return ret;
    }
}


Keep Daxing!!

Thursday, November 26, 2020

Extensions of Forms using COC in D365 FO/AX 7.0

 Hi guys, Today we see how to Extend the form by COC(chain of command) in D365 FO/ AX 7.0.



Form DataSource Extension:


[ExtensionOf(formDataSourceStr(CustGroup, CustGroup))]

final class CustGroupMy_Extension

{

    public void init()

    {

        CustGroup   custGroup;

        next init();

        while select forupdate custGroup

            where !custGroup.Description

        {

            ttsbegin;

            custGroup.Description = custGroup.CustGroup + ' ' + custGroup.Name;

            custGroup.update();

            ttscommit;

        }

         }

}


Form DataSource Field Extension:


[ExtensionOf(formDataFieldStr(CustGroup, CustGroup, Name))]

public final class CustGroup_Extension

{

    public void modified()

    {

        CustGroup       custGroup;

        FormDataSource  fds;

        FormDataObject  fd = any2Object(this) as FormDataObject;

        next Modified();

        fds = fd.datasource();
        //fds =  element.CustGroup_ds;

        custGroup = fds.cursor();

        custGroup.Description = custGroup.custGroup +' '+custGroup.name;

    }

}


Keep Daxing!!

Friday, August 28, 2020

How to add a Field and a Method to a standard Table in D365 F & O/AX 7

 

Hi guys ,Today we see how to add a field and Method to a standard Table in D365.


In D365 EXTENSIONs concept is  added.In 2012  only layering concept.

ADD Field :

Run visual studio As Administrator.

Click on Application Explorer.

Right click on CustGroup Table and click on Create extension.

Table add to your Project with '.model' suffix.

Add field in CustGroup table


ADD Method :

      For creating method we Have to create Class and that class 

  • must be final.
  • must be suffixed by _Extension.
  • must be decorated with the [ExtensionOf()] attribute.
Code

[ExtensionOf(tableStr(CustGroup))]

final class CustGroup_Extension

{

    public void insertName()

    {

        this.name= this.CustGroup;

    }

}


By using Event Handler We are adding this method to Modified Method of CustGroup Table.

For that we have to create Event Handler Class.


class CustGroup_EventHandler

{

    [DataEventHandler(tableStr(CustGroup), DataEventType::ModifiedField)]

    public static void CustGroup_onInserting(Common sender, DataEventArgs evnetArgs)

    {

        CustGroup custGroup = sender as CustGroup;

        CustGroup.insertName();

    }

}


Keep Daxing!!