// <summary> /// Gets the primary index of a table. /// </summary> /// <param name="_tableName"> /// A table name. /// </param> /// <returns> /// Returns field id. /// </returns> public static Container getPrimaryIndex(TableName _tableName) { SysDictIndex keyIndex; DictField dictField; int fieldIndex; container res, isMandatory; SysDictTable sysDictTable = new SysDictTable(tableName2id(_tableName)); if(sysDictTable) { TableId tableId = sysDictTable.id(); keyIndex = new SysDictIndex(tableId, sysDictTable.primaryIndex()); if (keyIndex) { for (fieldIndex = 1; fieldIndex <= keyIndex.numberOfFields(); fieldIndex++) { if (fieldId2name(tableId, keyIndex.field(fieldIndex)) != fieldStr(DMFDefinitionGroupExecution,ExecutionId) && fieldId2name(tableId, keyIndex.field(fieldIndex)) != fieldStr(DMFDefinitionGroupExecution,DefinitionGroup)) { dictField = new DictField(tableId, keyIndex.field(fieldIndex)); res += dictField.id(); isMandatory += dictField.mandatory(); } } } } return [res, isMandatory]; }
This blog is contains coding reference related to Microsoft AX 2012 and D365 finance and operations and Power platform
Showing posts with label Primary Index. Show all posts
Showing posts with label Primary Index. Show all posts
Monday, September 25, 2023
Gets the primary index of a table
Subscribe to:
Posts (Atom)