Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Customizing Boolean field

Posted on by 382

Hello everyone, 

I have created a table "Item Model" along with its list and card pages. The table contains one Boolean field i.e. "Default". I want a functionality that whenever I mark Default=true for one of the item. The rest of the entries with same item no. should be automatically set to default=false and should become non-editable and when I make the entry having default=true equal to false then the rest of the entries with same item no.  become editable. In the below is the example that I want. For Item No.=1000 I want that if one default is set to true then the rest of the entries with same item no. should be set to false and become non-editable. and if I change the default from true to false then the rest of the default named fields become editable. Make sure that the process must for only those entries that have same item no. Kindly help. Thank you. 

  

  • RE: Customizing Boolean field

    Thank you Tech Lucky, it worked.

  • Verified answer
    Tech-Lucky Profile Picture
    Tech-Lucky 796 on at
    RE: Customizing Boolean field

    The first part is you need to make other items with the same item No. as Default:= false for that you can use here the ModifyAll function Like the bellow

    write this code to Field "Default" OnValidate Trigger in Table
    var
    RecItemModel: Record "Item Model";

    RecItemModel .Reset();
    RecItemModel .Setrange("Item No.", Rec."Item No.");
    RecItemModel .Setfilter("Make Code",'<>%1', Rec."Make Code"); // if this is unique for other entries with the same item no otherwise this will not work try to use Primary Keys that makes the entries unique to prevent the current record to be modified
    if RecItemModel .findset then
     RecItemModel.Modifyall("Default",false);

    the editable or noneditable thing can be done with the help of Boolean variables on the Page level share your objects code if you still face issues to achieve this I will try to help you out in that as well.

    Please mark this answer verified if this was helpful.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans