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

Announcements

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Sanhthosh.Kumar.K Profile Picture

Sanhthosh.Kumar.K 2

#2
Raed Salah Bzour Profile Picture

Raed Salah Bzour 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans