web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Determine if field exists on Common Object

(0) ShareShare
ReportReport
Posted on by 670

Is there any way to determine dynamically if a field exists on a Common object?

I am looping through the field Ids from the DictTable object for a particular field against a Common object of the same type. Unfortunately I don't have any way to know if those fields exist on this particular instance of the Common object. So there are times when I get the following error (as an example, but can happen to any table/field combination):

Stack trace: Field 'PrimaryAddressLocation' in table 'DirPartyTable' has not been explicitly selected

I want to do something like this:

Common record = //Some process that populates a common record
DictTable dictTable = new DictTable(tblId); //Where tblId is the Id of the table that populated the Common record
DictField dictField;
FieldId fieldId = dictTable.fieldNext(0);

while(fieldId)
{
if(record.(fieldId) != null)
{
//perform some process
}
fieldId = dictTable.fieldNext(fieldId);
}

But when I try to check if record.(fieldId) exists I am getting the error above. Is there anyway to do this check dynamically like this?

I have the same question (0)
  • Verified answer
    Sukrut Parab Profile Picture
    71,735 Moderator on at

    Hi Alex ,

    Check method SysDatabaseLog method setData to see example. This might help you

     extFieldId = conpeek(changedFields, i);
                    dictField = new SysDictField(common.TableId, extFieldId);
    
                    if (common.(extFieldId) != dictField.nullValue() ||
                        orig.(extFieldId)   != dictField.nullValue())

  • Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at

    Note that the problem isn't about the field not existing, and therefore Sukrut's solution doesn't check that either. In fact, the solution would fail if the field didn't exist.

    The error means that the field exists but its value hasn't been fetched from database.

  • Verified answer
    Evaldas Profile Picture
    1,800 on at

    You can test if the field has been selected by calling isFieldDataRetrieved method.

    record.isFieldDataRetrieved(fieldId2Name(tableId, fieldId))

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 659

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 465 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 304 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans