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 102

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

  • Suggested answer
    Komi Siabi Profile Picture
    12,789 Most Valuable Professional on at
    RE: Uncheck other checkbox if check one check box on table method

    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.

  • Pavel Ioana Profile Picture
    102 on at
    RE: Uncheck other checkbox if check one check box on table method

    I have to override the modifiedField method on the table

  • Suggested answer
    Komi Siabi Profile Picture
    12,789 Most Valuable Professional on at
    RE: Uncheck other checkbox if check one check box on table method

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

  • Pavel Ioana Profile Picture
    102 on at
    RE: Uncheck other checkbox if check one check box on table method

    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
    12,789 Most Valuable Professional on at
    RE: Uncheck other checkbox if check one check box on table method

    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
    102 on at
    RE: Uncheck other checkbox if check one check box on table method

    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
    huijij Profile Picture
    19,811 on at
    RE: Uncheck other checkbox if check one check box on table method

    Hi Pavel,

    You can try something like this:

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

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,274 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,947 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans