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 :

Check if a field is mapped in an AOT map

nmaenpaa Profile Picture nmaenpaa 101,166 Moderator

When you work with AOT maps, it might be that not all related tables have mappings to all fields of your map. This can lead to runtime errors unless you handle the missing mappings in your code.

For example your map might contain fields Field1, Field2, Field3 and Field4, but only the first three fields are mapped to Table1, and only the last three fields are mapped to Table2. If you now assign a Table1 buffer into your map variable, and try to reference Field4, the compiler accepts your code and you can build it succesfully. But when the user is running the application, she will get error "Error executing code: The field with ID '0' does not exist in table '[MyMap]'."

In order to handle this scenario, you can use the SysDictField class to see if the field is mapped for this table:

if (SysDictTable::isFieldMapped(tableStr(MyMap), tableId2Name(myMap.TableId), fieldStr(MyMap, Field4)))
{
    // Handling for table buffer that have Field4 mapped
}
else
{
    // Handling for table buffer that don't have Field4 mapped
}

Comments

*This post is locked for comments