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 100

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

  • Suggested answer
    Johnson_Patrick Profile Picture
    100 on at
    RE: Make the Field Mandatory

    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.

  • Suggested answer
    Deekshitha Reddy Profile Picture
    219 on at
    RE: Make the Field Mandatory

    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
    Shrey Chauhan Profile Picture
    274 on at
    RE: Make the Field Mandatory

    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.

  • Johnson_Patrick Profile Picture
    100 on at
    RE: Make the Field Mandatory

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

  • Suggested answer
    Deekshitha Reddy Profile Picture
    219 on at
    RE: Make the Field Mandatory

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,001 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,837 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans