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
Shubham Joge 9Shubham Joge 9 

trigger on order object

Hello Guys,

I need your help in trigger ,
Trigger on order object where only two future order is aloowed in draft order for one account .
ANUTEJANUTEJ (Salesforce Developers) 
Hi Shubham,

Have you tried checking with a validation rule??

Looking forward to your response.

Regards,
Anutej
Shubham Joge 9Shubham Joge 9
because we want to check whether there is any existing draft order
if yes then we dont want to create a new one. And draft order Subtype is custompicklist with values as future order.
on account level we dont have roll ups from order as order and account are in look up relationship
so that's why we have to query
Shubham Joge 9Shubham Joge 9
because we want to check whether there is any existing draft order
if yes then we dont want to create a new one. And draft order Subtype is custompicklist with values as future order.
on account level we dont have roll ups from order as order and account are in look up relationship
so that's why we have to query @Anutej
ANUTEJANUTEJ (Salesforce Developers) 
Okay so I think you can have a formula field on account record that has a count of records and this value you can fetch and if the number is two then you need not insert or if the number is less than 2 you can insert that record.

Does this help?