Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

User is able to move to other records without selecting a mandatory field

Posted on by 5

Hi,

There is a customized string field which i am making mandatory on runtime after checking a standard checkbox field in SalesLine. The requirement is like if the user checked the checkbox and not filling any value in the customized mandatory field and moving to any other record or action pane tab there should be notification pop up saying like the filed value must be filled in. This is happening after user saves the record but not at the time when the user moves to other records or form without saving the record.

I have tried in active() but the issue is like when the form is getting opened that time this notification is showing 

The requirement is like if the user has not filled the value in the customized field after checking the checkbox and tries to move to any other record or tab that time the system should not allow the user to move by showing the notification.

Any help in this case will be appreciated. Thank you in advance.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: User is able to move to other records without selecting a mandatory field

    That would be something else then.

    But if you put your validation in validateWrite, the record can't be saved via the form if it doesn't pass the validation. That's how all the standard validations work, too, and you should use the same pattern.

  • Sarthak Mohanty Profile Picture
    Sarthak Mohanty 5 on at
    RE: User is able to move to other records without selecting a mandatory field

    I have put the debugger in both salesLine and SalesLineType class validatewrite(), but it is getting hit only when i am pressing ctrl+S, it seems Autosave functionality is not happening correctly.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: User is able to move to other records without selecting a mandatory field

    When the user moves to another record, the previous record is saved. So validateWrite is triggered and if it fails, the record is not saved. So it should fit your requirement perfectly.

    You can't move out of a record without saving it.

  • Sarthak Mohanty Profile Picture
    Sarthak Mohanty 5 on at
    RE: User is able to move to other records without selecting a mandatory field

    Thank you Nikolas for your quick response.

    Yes the checkbox field belongs to SalesLine.

    Validate Write i tried but this will get called while we save the record. We are getting notification while we save the record. The requirement is like once the user checks the checkbox , the customized field becomes mandatory and if the user moves to any other record or any form without saving, that time system should throw the notification and should not allow the user to move out of that record.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: User is able to move to other records without selecting a mandatory field

    And is this checkbox also a field in SalesLine? Or SalesTable? 

    In general, if you want to block the user from saving wrong kind of data, you should put your code in validateWrite method of the table or the form data source, depending on the scenario.

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

Product updates

Dynamics 365 release plans