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
Narasimha LNarasimha L 

Declaratively create logic in your org that prevents two Opportunities from being created on a single Account in a single day.

HI Dev's

Scenario :
-----------
Declaratively create logic in your org that prevents two Opportunities from being created on a single Account in a single day.
NagendraNagendra (Salesforce Developers) 
Hi Narasimha,

You could create a text field on Opportunity that is marked as "unique" and doesn't allow duplicate values. Then use a Workflow Rule and Field Update to update the field with the account/date combination eg:
AccountId & "-" & YEAR(CreatedDate) & "-" & MONTH(CreatedDate) & "-" & DAY(CreatedDate)
The workflow criteria would be true so that it fired all the time.

                                                 (OR)
One way would be to roll up the max opportunity date to the account, then have a validation rule check if the newly created opportunity date is equal to the custom rollup field on the account.

Please mark this as solved if it's resolved.

Best Regards,
Nagendra.
 
Narasimha LNarasimha L
Hi Nagendra,

Thanks for your reply.
It shows some error like -- Error: Incorrect parameter type for function 'YEAR()'. Expected Date, received DateTime