Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Get table field base type

Posted on by 99
 
       public boolean getBaseType()
        {
            boolean ret;
            DictField               dictField;
            FieldName                 tableFieldName = this.field1;
            TableName               tableNameFromRef = this.field2;
            DictTable               dictTable = new SysDictTable(tableName2Id(tableNameFromRef));
            while (tableFieldName)
            {
                dictField = dictTable.fieldObject(tableFieldName);
                myTable.FieldType = dictField.baseType();
            }
            return ret;
        }
 
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 229,963 Most Valuable Professional on at
    Get table field base type
    Note that the better place for your logic is modifiedField() method on the table, not modified() method of an individual form control. It's better for reusability and discoverablity.
     
    There you code may look like this:
    public void modifiedField(FieldId _fieldId)
    {
        switch (_fieldId)
        {
            case fieldNum(MyTable, MyFieldId):
                if (this.TableName && this.FieldName)
                {
                    this.FieldType = SysDictField::newName(this.TableName, this.FieldName).baseType();
                }
                else
                {
                    this.FieldType = Types::void;
                }
                break;
        }
    }
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,322 Super User 2024 Season 2 on at
    Get table field base type
    Hi User,

    I think your code in the while loop is erroring right? you don't need a while loop.

    Maybe try something like this and please update us if it works
      
    public boolean modified()
    {
        boolean ret;

        ret = super();

        if(ret)
        {
            TableId      tableId1  = tableName2Id(Grid_Tables.valueStr());
            FieldName    fieldName = Grid_FieldName.valueStr();
            FieldId      fieldId   = fieldName2Id(tableId1, tableFieldName);

            DictField  dictField = new DictField(tableId1, fieldId);

            TableX_ds.object(fieldNum(TableX, FieldType)).setValue(strFmt("%1",dictField.baseType()));
        }

        return ret;
    }


    Thanks,
    Layan Jweihan
    Please mark the answer as "Verified" if it solved your question. In order to help others as well

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,963 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans