Search code examples
propertiesaxaptadynamics-ax-2012x++

How to set in the Table methods field's properties from code?


I want to set field properties , in table method from code.

I would like to do as a Form

in modifiedField Table method, I wolud like to insered look like this code:

if(this.FieldControl == "valueToBlock")
{
    // I want to set here the field property 
    //this.Field_II allowEdit(false); 
}

It's possible to set the property from code in Table method ?

thanks community,

enjoy!


Solution

  • You can use dataSource result on the buffer. The result is FormDataSource if buffer source is from client form.

    If record changes you have to re-calculate this (create new method and call it from the table modifiedFiled and form DS active).

    public void modifiedField(FieldId _fieldId)
    {
        FormDataSource fds;    
        super(_fieldId);    
        switch (_fieldId)
        {
            case fieldNum(TableName,FieldI):
                if (this.isFormDataSource())
                {
                    fds = this.dataSource();
                    fds.object(fieldNum(MyTable, Field_II)).allowEdit(this.Field_I != "valueToBlock");
                }
                break;
        }
    }