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 :
Microsoft Dynamics AX (Archived)

Making a field mandatory and not be able to exit page until it is filled up

(0) ShareShare
ReportReport
Posted on by

So we developed a custom module  when clicking an action button the status is set to returned. This makes the field Reason Code form control  for the header and lines mandatory.

Problem is, you may still exit the form even if i set the form control mandatory after clicking the action button.

I tried overriding datasource methof ValidateWrite but it does not seem to do the job. Can anyone provide me a solution?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at
    RE: Making a field mandatory and not be able to exit page until it is filled up

    Hi reignheart05,

    In AX it's a standard behavior, when you create or edit a record and then can close a form without saving your changes.

    I suppose that on a button click you are updating a filed value and saving it, instead of this, you can try to modify value without saving the record. In this case when user will try to save it without populating mandatory fields he will get an error.  If user will press "Esc" to close the form without saving he won't save change to a status field as well, so record will be rolled back to initial state.

    It's impossible to prevent user to close the form because he always can terminate AX client using task manager or event turn off PC :)  So you need to develop your functionality in a way when you data is consistent on each step.

  • Suggested answer
    DavidGunawan Profile Picture
    1,381 on at
    RE: Making a field mandatory and not be able to exit page until it is filled up

    Hi,

    You can override canClose() method of the form. In this method you can do validation the value. If it's not set then you need return false. So the form will not able to be close even though by press ESC button.

  • Community Member Profile Picture
    on at
    RE: Making a field mandatory and not be able to exit page until it is filled up

    How do you modify a value without saving a record?  

    My problem is that users may exit record even though the field reason code is mandatory and may still exit and the record gets saved eitherway.

  • Community Member Profile Picture
    on at
    RE: Making a field mandatory and not be able to exit page until it is filled up

    Hi DavidGunawan,

    Thank you will try your suggestion.

  • Mea_ Profile Picture
    60,284 on at
    RE: Making a field mandatory and not be able to exit page until it is filled up

    What code do you have now ?

    Yes, you can go with canClose() method, but as I mentioned before, user can close form in not "gentle" manner and in this case you will have "broken" data in your application, if you don't believe that it could be done intentional, just imagine that he lost a connection with AOS or client crashed.

  • Community Member Profile Picture
    on at
    RE: Making a field mandatory and not be able to exit page until it is filled up

    Hi Ievgin,

    Just got your point.. you can force close such as ending process.

    Actually my action pane button. Just changes the status of the record and the line record.

    Then makes the reason code form as mandatory.

    I'm thinking of making another form that will get the lines and you may set the reason code in there. And if you don't "Ok" it should not save.

    It took me a while to figure out but this should really be similar to posting process for inventory(InventTransferParmShip). Except that it only updates status. 

  • Mea_ Profile Picture
    60,284 on at
    RE: Making a field mandatory and not be able to exit page until it is filled up

    That's a good idea. If user will provide a reason code you will change a status, otherwise you will do nothing.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans