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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

to trigger the error if second record is checked.

(0) ShareShare
ReportReport
Posted on by 1,836
hi ,
Everyone ,
I am having one checkbox field on form which is table field yesno so i want only single record on the form to be checked it should trigger error , how can i get it done plz guide me on this ,below is my form 
thanks,
Regards,
Dinesh
I have the same question (0)
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,779 Super User 2026 Season 1 on at
     
    You must use the validateWrite method.
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Dineshkarlekar Profile Picture
    1,836 on at
    hi ,
    Thanks for reply ,
     
    I am having issue if i write the code on validate it will check for current record , do i have to use loop or any condition to compare it with previous checked record ,can you please help me on this .
     
    thanks ,
    Regards
    Dinesh
  • Suggested answer
    Martin Dráb Profile Picture
    238,753 Most Valuable Professional on at
    Stop for a moment about what you want to achieve. Then you'll be able to answer questions like whether you need a loop for anything.
     
    You want to check if there is a record in database that has the checkbox ticked and it's not the current record. The way how you can query data is using a select statement. For example:
    if (this.Checked)
    {
        select firstOnly RecId from myTable
            where myTable.Checked
               && myTable.RecId != this.RecId;
    
        if (myTable.RecId)
        {
            ok = checkFailed(...);
        }
    }
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,779 Super User 2026 Season 1 on at
     
    try this :
        boolean validateWrite()
        {
    		boolean		ok;
    		MyTable		myTable;
    		
    		ok = super();
    		if(this.checked)
    		{
    			select myTable where myTable.checked == NoYes::Yes
    			&& myTable.RecId != this.RecId;
    			
    			if(myTable)
    			{
    				ok = checkFailed(strFmt("Erreur !"));
    			}
    		}
    		
    		return ok;
        }
    Best regards,
    Mohamed Amine MAHMOUDI
  • Suggested answer
    Layan Jwei Profile Picture
    8,165 Super User 2026 Season 1 on at
    Hi Dinesh,

    Your explanation for the requirement is not very clear. If I understood correctly, only one record in the table can have Checked =yes?
     
    Would you like the error to appear when you directly tick the box and navigate to another field? In this case you can use the validateField method
    or if you would like the error to appear when you click save, then you can use validateWrite method

    And yes you need to check that current record recId  is not equal to the record where the checked field is yes. In order to know if there is more than one record with checked =yes

    Thanks,
    Layan Jweihan
  • Layan Jwei Profile Picture
    8,165 Super User 2026 Season 1 on at
    Hi,
     
    Is your question answered? If yes, then please verify the answers that helped.
  • Suggested answer
    Deepak Agarwal Profile Picture
    8,602 on at
    Why not to use an ENUM for Purhcase type, by that way you will alwasys select just one value and you can avoid all other things. 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 509 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 375

#3
Adis Profile Picture

Adis 268 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans