I hope you all are doing well. I am beginner to salesforce and I am working on one of the requirement. Below are the details:
I am using SOSL to retrieve accounts based on some condition and need to show an account based on precedence on Status field.
There can be more than 2 accounts as well.
Example 1: If 2 accounts are retrieved by SOSL and both accounts have RETAIN as status, then it should return any of 2 accounts.
Example 2: If 3 accounts are retrieved by SOSL and all of them have different status(RETAIN, GRANTED, OTHER) then it should return account with status as RG
I have tried using so many if-else conditions but results are not expected when there are complex scenarios. I would like to know if there is any approach I can use here using apex?