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, ...
Answered

Disable all records on grid except current/newly created in D365FO

(0) ShareShare
ReportReport
Posted on by 2,114

Hi Techies,

I hope you are doing well.

I have one urgent requirement need to deliver.

Below form shows a header and each revision number have lines also which has separate line table.

Requirement is,

1) whenever user create a new record only that record needs to be editable including lines and all previous records[Header(except 'Active' field) and lines] should be non-editable.

For example-User created first record 'DAT-000001', it should be editable until user creates second record. So here, when user creates 'DAT-000002', it should disable 'DAT-000001'[both header(except 'Active' field) and line fields].

and secondly,

2) Active field should always be editable.

pastedimage1632321487483v1.png

I hope I am able to explain it properly, can anyone help me in this please.

Any response is appreciated.

Thanks in advance!

I have the same question (0)
  • Verified answer
    André Arnaud de Calavon Profile Picture
    301,035 Super User 2025 Season 2 on at

    Hi Sangram,

    On the active() method of the datasource you can add x++ logic to enable or disable editing for data sources. In this case, you can evaluate if there are records with a higher RecId number or a later timestamp for the modified date and time. If so, then the data source needs to be disabled for editing.

  • Verified answer
    huijij Profile Picture
    19,811 on at

    Hi Sangram,

    In this case,you can set the condition as when the column of grid has the largest revision number or has the Active field then the column is editable and the rest to be uneditable, you can refer to the x code to suppress the edit button of the system:

    FormCommandButtonControl editButton;
    
        public void init()
        {
            #SysSystemDefinedButtons
    
            super();
    
            editButton= this.control(this.controlId(#SystemDefinedViewEditButton)) as FormCommandButtonControl; 
            editButton.visible(false); 
        }

    docs.microsoft.com/.../system-defined-buttons

  • Sangram Shinde Profile Picture
    2,114 on at

    Thank you Andre, but is it possible to keep enabled single record and disable rest all, can you help X++ code if you can.

  • Verified answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    Since the active method runs every time you change a row, you can enable the datasource to true/false according to the row you are on.

    The problem is where you want to change only one column. In this case, disabling the ds will not work. You need to disable the fields other than the ones you want (it is possible to find examples on the internet, I shared an example below, it disabled two ds. I did not examine the code, but this is the logic of the business)

    community.dynamics.com/.../how-to-disable-editable-for-all-of-the-fields-except-two-in-a- form-for-a-selected-record-only/744432

    The only trouble is, for me, this code is not a code that I want to run on active. But in your case you have to write to active. There is a possibility of slowing it down, you need to test and decide.

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 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans