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

Notifications

Announcements

No record found.

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 648

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,710 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
    237,965 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 503 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 434 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans