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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Form grid field enable if condition met

(1) ShareShare
ReportReport
Posted on by 229
Hello 

I 've got a form grid where i have rows, i need to create some behavior.

When i click the checkbox on row1, the other checkbox from row2(row3,4 ...) must be disable,  but not the one i checked first and when i uncheck the checkbox on row1, the other checkbox from row2 must be enable.

How to do that ?


Here's the grid sample.

Regards
I have the same question (0)
  • Layan Jwei Profile Picture
    8,284 Super User 2026 Season 2 on at
    Hi,
     
    Do you mean that if one checkBox in the grid is ticked as true, then all other records should have their checkBoxes as disabled? And if no checkBox in the grid is ticked as true, then all checkBoxes should be enabled?
     
    If yes, then on the modified method of the checkBox, you can check if the current value is true and disable all other checkboxes in the grid (recId != CurrentRecId) and if the value is false, then you can enable all of them. I think you would also need the code in the init method of the form so that the code is reflected when you first open the form
     
    Maybe show us your code and we can help you from there
     
    Or why not on the validate method only allow one checkbox to be ticked as true? Would it suit your requirement? I mean if you try to tick another checkBox a warning will appear saying only one checkBox can be set as true and it will prevent you from saving
     
    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future.
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    In the active method of that line datasource just check if any of the other line is checked. If checked then make the current row enum field disabled and vice versa.
  • Awaxx Profile Picture
    229 on at
    Hi guys, 

    Thanks for replying.

    You must understand that when i'm checking the checkbox on a specific row, only other ones must be disabled, the checked one must be editable in case i need to uncheck it to make other ones enabled.

    For now, i tried many ways but i'm not able to make enable the checked on when disabling the others.

    Do you have some clues ?

    Regards.
  • Layan Jwei Profile Picture
    8,284 Super User 2026 Season 2 on at
    Hi Awwax,
     
    Yes i understand that's why i said where recId!= currentRecId and that's why i mentioned modified method and init method

    So for example in general, if let's say the grid is salesLine, and you would like to get all other records except for the one you are standing on, then you would write sth like this:
    While select salesLine where salesLine.SalesId == this.SalesId && salesLine.RecId != this.RecId

    Can you show us what you did and tell us the wrong behavior that happens so that we can help

    The active method could also work as bharani suggested -- maybe it's a better suggestion and maybe what i suggested at first won't work.
    You could write sth that says if no checkBox is ticked as true in the whole grid then make all editable
    If one is ticked as true, then make others disabled
    ​​​​​​​
    So maybe try sth like this:
    [ExtensionOf(formDataSourceStr(SalesTable, SalesLine))]
    final class SalesTableFormDatasource_Extension
    {
        public int active()
        {
            int ret;
    
            ret = next active();
    
            if(ret)
            {
                SalesLine salesLineLocal = this.cursor();
    
                SalesLine salesLineCount;
                select count(RecId) from salesLineCount where salesLineCount.SalesId == salesLineLocal.SalesId && salesLineCount.CheckBoxField == NoYes::Yes ;
    
                If (salesLineLocal.CheckBoxField == NoYes::Yes || salesLineCount.RecId == 0)
                {
                    this.object(fieldNum(salesLine, CheckBoxField)).allowEdit(true);
                }
                else
                {
                    this.object(fieldNum(salesLine,CheckBoxField)).allowEdit(false);
                }
            }
    
            return ret;
        }
    }
    

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future.
  • Waed Ayyad Profile Picture
    9,214 Super User 2026 Season 2 on at

    Hi,

    I have a question about this requirement: what should be the default case? Do all lines have to be enabled or disabled?

    Thanks,
    Waed Ayyad
     
     
  • Verified answer
    Awaxx Profile Picture
    229 on at
    Hello guys,

    I used a validate method and add a warning, that's seems to me the best solution.

    ​​​​​​​Thanks guys

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 341 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 312

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 262 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans