Skip to main content

Notifications

Announcements

No record found.

Business Central forum
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

Categories:
  • 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.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans