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
Jose ZunigaJose Zuniga 

Sharing objects, triggers, and avoiding @future methods

I need to find out how a sharing group can be empty?
I am trying to implement an algorithm like this:
I want to share an object O using a sharing group G
Before inserting the object O create an empty group G
After inserting the object add the "people" that O will be shared with to G, possibly rename G and "attach" G to O so this object will be shared through G.
Is this possible? If so I might be able to avoid the use of @future methods and Salesforce is so problematic with them.
NagendraNagendra (Salesforce Developers) 
Hi Jose,

First and foremost sincerely regret the inconvenience for the delayed reply.

Groups are a Setup object, so they will necessarily need to be separated by, transaction. In order to perform this transaction's, you need to use Batchable, Schedulable, Queuable, or Future methods.

If still it's not clear I kindly request you to please elaborate what exactly you are looking for so that it helps in resulting of easy troubleshooting of the problem.

Hope this helps.

Mark, it as solved if it's resolved.

Best Regards,