- Create a custom field to show whether that account has closed won opportunity
- Create a custom button to get the number of closed won Accounts in below ranges a) >50 km b) Accounts between 30 km and 50 km c) less than 30 km
Record triggered flow with a condition set if opportunity stage=closedWon and if yes update the custom field as a checkbox with a tick.
The next part is to develop an apex code which fetches all these closedWon accounts in the flow and checks the distance with all the nearby accounts.And three conditions are to be set for each distance range update each custom field in the account.
I have used an invocable method to connect to the flow and getAccount queries the shipping address of the closedWon Accounts.Now I have to obtain the location of each closed won Account and check for nearby accounts.If there are any accounts within 50km range for each range(<30,30-50,>50)the value should be updated in the custom field of account.