1 – Avoid using Webservices inside Sales Cloud in your groovy.

Try to always find a way to use only groovy and avoid as much a possible usage of Webservices.

Pure groovy scripts in general execute faster.

 

2 – Avoid using in your queries non indexed attributes.

Is best to try to use a primary key or a foreign key when running  query using newView() function.

Usually this attributes are Ids like OptyId, CustomerID, for custom DCL fields is DCLname_Id_c

 

3 – If you hit error like Post threshold limit reached try doing something like this in your code

if(API_NAME_FIELD != value){

setAttribute(‘API_NAME_FIELD ‘,value)

}

 

4 – Avoid the use of newView() API if we already have a Related Accessor

If in the pallet you have a Related Object or Related Collection for the object you try to access, use those instead of newView()

 

5 – Be careful when using formula fields

Formula fields can execute multiple times during the page/form execution

So if you have some query written on a formula field then that query can execute several times while you open a page or navigate through the subatbs.

 

6 – Don’t  use to many triggers.

Try to make the logic of your customization with a minimum necessary number of triggers.

Triggers push data to the database so to have to many, may cause performance issues.

 

7 – Use the right tool for the right task.

For example if you want to make a validation on a single field, make that at level of the field not at the level of the object, would be much more efficient.

 

8 – Try not to create chain reactions.

Try to avoid situations when a trigger fires and that triggers execution of a workflow and that workflow triggers execution of another workflow or  a trigger and so on…

If this chain is not thought well enough you will eventually hit error : Record was locked by another  user

 

9 – Updatable/required  behave as formula field do, so they will execute multiple times , so careful with the code written in them.

 

10 –  And finally remember OSC groovy console is not a  full fledged IDE development environment like Eclipse, Visual studio, Netbeans, Codeblocks so on…

So it has it’s limits like not all JAVA classes will work.

 

So this are just few things to keep in mind when making your scripts and customization.

Hope this will help you avoid unpleasant situations.

Leave a Reply

Your email address will not be published. Required fields are marked *