Tuesday, July 30, 2019

How to get all the table names (Standard/Customized) in D365? - solution

Issue: How to get all the table names (Standard/Customized) in D365?

Solution: Below lookup method should be implemented to get the desired lookup.

              /// <summary>
        /// The method will lookup all the table names.
        /// </summary>
        public void lookup()
        {
            Query                   lookupQuery;
            QueryBuildDataSource    qbds;
            SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tablenum(SqlDictionary), this);

            // Display the Name field in the lookup form.
            sysTableLookup.addLookupfield(fieldnum(SqlDictionary, Name));

            lookupQuery = new Query();
            qbds = lookupQuery.addDataSource(tablenum(SqlDictionary));
            qbds.addRange(fieldNum(SqlDictionary, fieldId)).value(queryValue(0));
            qbds.addSortField(fieldNum(SqlDictionary, Name), SortOrder::Ascending);
            qbds.addRange(fieldNum(SqlDictionary, shadow)).value(queryValue(0));
            qbds.addRange(fieldNum(SqlDictionary, flags)).value(queryValue(0));

            sysTableLookup.parmQuery(lookupQuery);

            sysTableLookup.performFormLookup();
        }

No comments:

Post a Comment