Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Make the Field Mandatory

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
    Johnson_Patrick 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
    Deekshitha Reddy 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
    Shrey Chauhan 288 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
    Johnson_Patrick 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
    Deekshitha Reddy 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans