Dynamics Ax Disable / Enable all datasource fields

Sometimes you want to disable all fields on a form’s datasource and enable some of them afterwards. Put the following piece of code in the Global class and you can call it from wherever you like.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public static void LIBSetAllTableFields(FormDataSource _formDataSource,Boolean _value)
{
    DictTable       dictTable = new DictTable(_formDataSource.table());
    int             i;
    int             fieldNumber;
    ;
    for(i = 1;i < = dictTable.fieldCnt();i++)
    {
        fieldNumber = dictTable.fieldCnt2Id(i);
        if(_formDataSource.object(fieldNumber))
        {
            _formDataSource.object(fieldNumber).allowEdit(_value);
        }
    }
}
Warning: count(): Parameter must be an array or an object that implements Countable in /customers/5/2/1/ksaelen.be/httpd.www/wordpresses/dynamicsaxblog/wp-includes/class-wp-comment-query.php on line 399

Leave a Comment Yourself

Your email address will not be published. Required fields are marked *