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 :
Microsoft Dynamics AX (Archived)

Validate fieldvalue against relation

(0) ShareShare
ReportReport
Posted on by 811

Hi,

let's say you have 3 parameters:

1) TableId

2) FieldId

3) FieldValue

Is there any (standard) way of checking if the fieldvalue is an ok value for that field (using its relations - direct or via EDT) in code? (without trying an insert or any of that)

Thanks for any help,

 

Sven

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Denis Patrakov Profile Picture
    on at

    You will generally need a table buffer to validate a field as its value might depend on other field values i.e. it might be valid only in some context. If you have a table buffer then you can use a code like this:

    boolean ok;
    anytype prevValue;
    ;
    // ...
    prevValue = record.(fieldId);
    record.(fieldId) = newValue;
    ok = record.validateField(fieldId);
    if (!ok)
    {
        record.(fieldId) = prevValue;
    }

    Note:

    • the validateField() method might be overloaded on a table to implement some additional checks for a field besides the ones that the kernel performs;
    • you should check if the field is an array field (like Dimension) and in that case validate it on a per-element basis otherwise the kernel check will fail and might even modify some field values!
    • you cannot use a variable of type anytype for different types of values in the same context as it becomes "typed" after the first assignment.

    See also \Classes\SysConsistencyCheck\kernelCheckRecord

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans