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, ...
Unanswered

Validation error in x++

(0) ShareShare
ReportReport
Posted on by 1,215

Hi guys,

i have a validation in setup once i mentioned in status ::Error and Check box set "Yes".

in main form while saving i want to reason code "Must be filled in reason code".

issue:

but i am not mentioned above two status while saving gave error "Must be filled in reason code". what can be issue ?

 public boolean checkMandatoryReasonCode()
    {
        boolean ret = true;
        SDSExcuseSetup      setup = SDSExcuseSetup::find(this.ExcuseId);

        if (setup.MandatoryNotificationType == SDSNotificationType::Error
            ||setup.ReasonCode == NoYes::Yes && !this.ReasonCode)
        {
            ret = checkFailed(strFmt("@SDS4015"));
           
        }

        return ret;
    }

i mapped in above code in validateWrite

like : ret = ret && this.checkMandatoryReasonCode();

what did am i missing ?

Thanks

I have the same question (0)
  • Martin Dráb Profile Picture
    237,803 Most Valuable Professional on at

    Debug the code to see what's going on.

    Maybe checkMandatoryReasonCode() isn't called at all, because ret in validateWrite() is already false.

    Maybe those three conditions aren't interpreted in the order you expect. I strongly recommend that you should use parentheses rather than depending on the operator precedence. It'll prevent this kind of bugs and make your code easier to read and maintain.

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 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans
Liquid error: parsing "/globalsearch/?q=Intel(r" - Not enough )'s.