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 :
Small and medium business | Business Central, N...
Suggested Answer

Make the Field Mandatory

(0) ShareShare
ReportReport
Posted on by 102

Hi,

I want to make non-primary keys of the table mandatory on a list part page. For eg: If i am working with Sales Order Subform Page and there is a field "Expiration Date" field on the sales lines. If the user doesn't enter the Expiration Date on the lines before exiting from the line, the system should throw error asking to fill the field and stay on the page. User can revert back the changes if he doesn't wish to specify the expiration date.

As simple as it might sound, I have tried it using ShowMandatory, NotBlank & Testfields yet it doesnt work the way, i want it to work. 

if anybody had solved this before, please comment

Thanks

Johnson Patrick

I have the same question (0)
  • Suggested answer
    Deekshitha Reddy Profile Picture
    219 on at

    You can code on trigger OnValidate of the specified field.

    IF Rec."Expiration Date"='' THEN//Single Quotation Mark without space.
    Error('enter the expiration date');

    Hope this helps.

  • Johnson_Patrick Profile Picture
    102 on at

    No that doesnt work. System throws error immediately after the record is inserted.

  • Suggested answer
    Shrey Chauhan Profile Picture
    284 on at

    You can use the

    ShowMandatory = true;

    Importance = Promoted;

    Or

    You can code on trigger OnValidate of the specified field.

    IF Rec."Expiration Date"='' THEN//Single Quotation Mark without space.

    Error('enter the expiration date');

    Thank You.

  • Suggested answer
    Deekshitha Reddy Profile Picture
    219 on at

    Try giving trigger OnValidate on any other field which is after the specified field.

    It might work.

    You can also try it on Action Button (Trigger OnAction).

    You can try page triggers trigger "OnClosePage"

     trigger OnClosePage()
        begin
            if rec.ExpirationDate = '' then//Single Quotation Marks without space
                Error('Enter the date');
        end;

    Please let me know.

    Hope this helps.

  • Suggested answer
    Johnson_Patrick Profile Picture
    102 on at

    I solved the problem by making the page as DelayedInsert true & then using testfield i validated the fields which are mandatory on OnInsert & OnModify triggers of the table.

    Thanks for your suggestions.

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans