web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

I have the same question (0)
  • 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
    284 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 4,252

#2
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,117

#3
Sumit Singh Profile Picture

Sumit Singh 2,956

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans