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,019

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!

  • Verified answer
    ergun sahin Profile Picture
    8,816 Moderator on at
    RE: Disable all records on grid except current/newly created in D365FO

    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.

  • Sangram Shinde Profile Picture
    2,019 on at
    RE: Disable all records on grid except current/newly created in D365FO

    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
    huijij Profile Picture
    19,811 on at
    RE: Disable all records on grid except current/newly created in D365FO

    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

  • Verified answer
    André Arnaud de Calavon Profile Picture
    293,209 Super User 2025 Season 1 on at
    RE: Disable all records on grid except current/newly created in D365FO

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,209 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,923 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans