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
liron169liron169 

Sharing rules calculation

Hi,
We have several objects that calculation of their sharing rules done in apex code.
This code is complex and dirty and hard to maintain. So I review it - and found option to move it into the UI - means calculate it with sharing rules base criteria.


There are 2 optional problem:

1.We might need to increase the available sharing rules criteria. Current limit is 50, and SF support already confirm that we can increase it, but the concern is if it will affect performance significantly?
(currently we will have 20 criteria, but in future it might increase to ~60)

2.Might need to use complex criteria. Would that reduce the performance significantly?
e.g.:   (6 AND ((2 AND (3 OR 4 OR 5)) OR (1 AND 3))) OR (7 AND 8)


Does someone have exprience with this and can advise?
Thanks.
Best Answer chosen by liron169
Vinita_SFDCVinita_SFDC
Hi,

Lot sharing rules are not recommended. Now if we apply it using code then also there will be an impact on performance, so i am advising you to go for apex coding and check is it having significant impact on performance.

All Answers

Vinita_SFDCVinita_SFDC
Hello,

As per best practice it is advised to have minimum number of sharing rules. I would suggest you to go by second approach instead of increasing number of sharing rules.

Also you can test it out in sandbox/ test org first.
liron169liron169
Hi,

What do you mesn by second approach?
The other approach will be to keep using apex code.

I can replace the code by using both number of criteria, and each criteria might need complex logic.
Should I keep it in the code?
Vinita_SFDCVinita_SFDC
Hi,

Lot sharing rules are not recommended. Now if we apply it using code then also there will be an impact on performance, so i am advising you to go for apex coding and check is it having significant impact on performance.
This was selected as the best answer
liron169liron169
Thank you,
Indeed I'll do some tests on performance, of with code/sharing rules, and then decide
liron169liron169
Must say, I tested the sharing rules with 5 criteria (complex), 10, 15  and then 20.
I almost didn't notice change in performance at all.

I'll keep testing it