function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kali charankali charan 

Finding least value in list

Hi everyone,

    I have written the trigger .In that i have a list of contacts and in that i have number field amount.I have multiple amounts and ia want to find the least amount value and it a check box should be populated on tha account aobject.please suggest me in this scenario.

Thanks.
 
Dilip_VDilip_V
Hi Charan,

Use order by in SOQL query.
select id,name,(select Id,name,Amount__C from contacts Order by Amount__c ASC) from Account
The first element in the list have least amount value.

Thanks.