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
Tecnova AdminTecnova Admin 

I want to keep a cap of 200 companies in salesforce as we have multiple users and we dont want to add anymore companies above 200. How can i do that. Please suggest...

Tecnova AdminTecnova Admin
I want to keep a cap of 200 companies in salesforce as we have multiple users and we dont want them to add anymore companies above 200. How can i do that. Please suggest...
Grazitti TeamGrazitti Team
Hi Tecnova,

This can be done by using trigger on before insert event of companies. On before insert you can count no. of records in the object and if they are less than 200 then insert otherwise not.

trigger <TRIGGER_NAME> on <OBJECT_NAME>(before insert){
Integer i = select count() from OBJECT_NAME;
if(i<200){
THEN WRITE YOUR INSERT CODE HERE
}else{
YOUR ERROR MESSAGE
}
}

let us know if you have any question .
please don't Forget to Mark this as your best answer if it works fine for you

Regards,
Grazitti Team
Web: www.grazitti.com.

Tecnova AdminTecnova Admin
I dont know how to add code as i am new to it ???

Hope you got the qustion correctly as we dont want other users to add more than 200 companies.
Avidev9Avidev9
Best way to learn how to add code is the documentation!
You can find the same here https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_qs_HelloWorld.htm