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

Uncheck other checkbox if check one check box on table method

(0) ShareShare
ReportReport
Posted on by 106

Hey! How should I write the code on the modifiedField method on the table so that a check box is unchecked when another is checked?

The name of the field is DefaultValue (checkbox) and it is an Enum of type NoYes and the table is PI_MarketingCategory

I have the same question (0)
  • Suggested answer
    huijij Profile Picture
    19,811 on at

    Hi Pavel,

    You can try something like this:

    if(PI_MarketingCategory.DefaultValue == NoYes::Yes){
    
    PI_MarketingCategory.xxx == NoYes::No
    
    }
    
    

  • Pavel Ioana Profile Picture
    106 on at

    This doesn't work for me. When I check a checkbox in the DefaultValue field, the others must be unchecked. In the end, I must be able to have only one checked value per column. It is about the same field and not about different fields.

    Being the method on the table, shouldn't I use "this"?

    In the end it should look like this

    pastedimage1661410495163v1.png

  • Suggested answer
    Komi Siabi Profile Picture
    13,109 Most Valuable Professional on at

    Hello , 

    You would have to update other record(s).

    PI_MarketingCategory    PI_MarketingCategory;
    
    ttsbeggin;
    if(this.DefaultValue == NoYes::Yes)
    {
    
        while select forupdate PI_MarketingCategory where PI_MarketingCategory.DefaultValue = NoYes::Yes
        {
            PI_MarketingCategory.DefaultValue =NoYes::No;
            PI_MarketingCategory.update();
        }
        
    }
    ttscommit;

  • Pavel Ioana Profile Picture
    106 on at

    This solution allows me to check only one default value, but it does not automatically uncheck the box when I set another value.

  • Suggested answer
    Komi Siabi Profile Picture
    13,109 Most Valuable Professional on at

    On which part of the form did you insert this code ?

  • Pavel Ioana Profile Picture
    106 on at

    I have to override the modifiedField method on the table

  • Suggested answer
    Komi Siabi Profile Picture
    13,109 Most Valuable Professional on at

    Hello Pavel,

    Kindly use this on the modifiedField method of the table.

    // Table
    public void modifiedField(FieldId _fieldId)
    {
        kwstABLE    kwstABLE;
        super(_fieldId);
    
        switch(_fieldId)
        {
    
            case fieldNum(kwstABLE,defaultValue):
            ttsBegin;
            while select forupdate kwstABLE where kwstABLE.MarketingCategory != this.MarketingCategory
                {
                    kwstABLE.DefaultValue =NoYes::No;
                    kwstABLE.update();
                }
            ttsCommit;
        }
    }

    This does the actual work. After you would need to refresh the form with this.

    Kindly overide the modieldField method on the form for your DefaultValue field.

    /// DefaultValue field on the form
    public boolean modified()
    {
        boolean ret;
    
        ret = super();
        kwstABLE_ds.refresh();
        kwstABLE_ds.research(true);
        return ret;
    }

    I tested this and it worked. If you have any challenge please do let me know.

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

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans