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
Swaroopa Akula 1Swaroopa Akula 1 

check the opportunity and create new opportunity based on conditions

I have "Type" field values- New logo, New logo- deployment in oppty.

I have to allow the users to select Type value "New logo - deployemtn" whenever the old opporunity has "New logo" and closed date should be in within a year.
example: 1 account has 5 oppotunities and 1 oppty has Type="New logo" and close date is 3/27/2019. If i wanted to create a new opportunity with "New logo - deployemtn" type, it should check the previous opprty and its closed date. if that is in within a year of time then only we should allow the users to create a new opprotunity with type"New logo- deployement". how can i achieve this?
 
Ajay K DubediAjay K Dubedi
Hi Swaroopa,
You need to follow some steps:
1. Create an apex class.
2. Querry all the Opportunity that having closed date within a year of time and save that record in a list.
3. Check the size of the list.
4. If the size is greater then 0 then write code for creating  Opportunity that having type "New logo- deployment".

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi