dinsdag 27 september 2011

How to Use Number Sequence Engine Efficiently with Dynamics AX Forms

See http://www.amer-ax.com/2010/06/how-to-use-number-sequence-engine-efficiently/

Global::allowEditFieldsOnFormDS_W

Set allowEdit property on every field in a form DataSource.

client static public void allowEditFieldsOnFormDS_W(FormDataSource _dataSource, boolean _allowEdit)
{
    DictTable       dictTable = new DictTable(_dataSource.table());
    DictField       dictField;
    FormDataObject  dataObject;
    int         cx, idx;

    for(cx = 1; cx <= dictTable.fieldCnt(); cx ++)
    {
        dictField = dictTable.fieldObject(dictTable.fieldCnt2Id(cx));

        if(! dictField.isSystem())
        {
            for(idx = 1; idx <= dictField.arraySize(); idx++)
            {
                dataObject = _dataSource.object(fieldId2Ext(dictField.id(), idx));
                if (dataObject)
                {
                    dataObject.allowEdit(_allowEdit);
                }
            }
        }
    }
}