web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Prevent changed of grid selection

(0) ShareShare
ReportReport
Posted on by 48

Hi,

I want to prevent user from switching to other record in grid, similar to 'ProdRoute' Form. If you create a new record via new button on that forms action pane, a new column is created in the grid. however if you dont fill all mandatory fields and try to select another record, a warning is shown and the selection doesn't change until you give all information. can you give me an idea on how to do that? i tried with overwritign leaverecord, validatewrite and active method with no success.

best regards

I have the same question (0)
  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi erpdell,

    Do you need this for the production route form or for another one?

    Do you have any other information that can be shared?

    Best regards,

    Ludwig

  • Suggested answer
    Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    If the field is always mandatory, simply set its Mandatory property to Yes.

    If it's conditional, write the logic in validateWrite() (on table if it should be used across forms, on the form if it's specific a the single form) and return false if the validation failed.

  • CU28041408-0 Profile Picture
    48 on at

    Thanks for your reply. I've already set the mandatory property for all fields to yes. However, it does not prevent the user from selecting another row. Same thing applies, if I overwrite the validateWrite() method.  So I suppose this isn't the desired behaviour, right?

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    If the validation fails, the selection is not expected to move to another grid line. Are you sure that you compiled your code?

    Can you share some screenshots with us to illustrate what you did and how the system behaves? Thanks!

  • CU28041408-0 Profile Picture
    48 on at

    I've made a standalone form, which is similar to the prodroute form: In our productions, quality controls take place between almost every step of the production process. If defects are found during quality control, reworking should be done before production continues. Rework steps are normal production steps, which are only identified by an additional NoYes field in the ProdRoute table.The form I am implementing is designed to allow users to insert these rework steps (for security and ease of use, we do not want to provide users with the full ProdRoute form, therefore I am creating this new form).  If a user now creates a new rework operation (inserts a new ProdRoute record), he should not be able to change the line until he has entered all the information required.

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Thanks for the explanation. Could you share the requested screenshots? For troubleshooting these kinds of issues it's required to look into the details. Thanks!

  • Martin Dráb Profile Picture
    237,959 Most Valuable Professional on at

    These things are used on almost every table in AX, therefore it's unlikely that it's all broken. More likely, your implementation is incorrect.

    Regarding Mandatory property, make sure you set it on the table field, not in the form.

    Regarding your code in validateWrite(), please show it to us. We can't find bugs in code that you've never shown to us. Also, please tell us what you found when you debugged your code.

  • CU28041408-0 Profile Picture
    48 on at

    Yes I see that it's working for other Forms (e.g. the ProdRoute form). I've set the mandatory property in the form. I don't want to set it on the ProdTable itself, as that may break any logic for other forms? The code I tried for validateWrite() method is very basic:

    private boolean isValid()
    {
        if(!prodRoute.OprId)
            return false;
        if(!prodRoute.ProcessTime)
            return false;
        if(!prodRoute.ProcessPerQty)
            return false;
        if(!prodRoute.WrkCtrIdCost)
            return false;
        if(!prodRoute.RouteGroupId)
            return false;
        return true;
    }

    public boolean validateWrite()
    {
        return this.isValid();
    }

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    Did you debug it? Does your validateWrite() method return false, but the user can still select another record in the grid?

  • CU28041408-0 Profile Picture
    48 on at

    validateWrite() is not getting called

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans