You need to sign in to do that
Don't have an account?
beckywillis
Auto Follow Community Members - Why is my code not working?
A previous Developer in my org included this code in our Community Member Registration class:
private void addAccountOwnerFollow ()
{
/*Auotmatically have the account owner follow the new community user*/
try
{
EntitySubscription es = new EntitySubscription();
es.ParentId = newCommunityUser.Id;
es.SubscriberId = userAccount.OwnerId;
insert es;
}
It does not seem to be working - so is something wrong with it, or is auto-following community members when they register simply not possible for owners? (Yes, I've looked into the follower limit and that's not the case.)
private void addAccountOwnerFollow ()
{
/*Auotmatically have the account owner follow the new community user*/
try
{
EntitySubscription es = new EntitySubscription();
es.ParentId = newCommunityUser.Id;
es.SubscriberId = userAccount.OwnerId;
insert es;
}
It does not seem to be working - so is something wrong with it, or is auto-following community members when they register simply not possible for owners? (Yes, I've looked into the follower limit and that's not the case.)
Please check with below link from forums community with similar issue and suggested workaround.
- https://developer.salesforce.com/forums/?id=906F00000009AEUIA2
Hope this helps.Please mark this as solved if it's resolved.
Regards,
Nagendra.
private void addAccountOwnerFollow ()
{
/*Auotmatically have the account owner follow the new community user*/
try
{
Id aid = trigger.new[0].Id;
EntitySubscription es = new EntitySubscription();
es.NetworkId = Network.getNetworkId();
es.ParentId = newCommunityUser.Id;
es.SubscriberId = userAccount.OwnerId;
insert es;
}
catch (Exception e)
{
system.debug(logginglevel.ERROR, 'Error in CommunitiesSelfRegController:addAccountOwnerFollow at ' + e.getLineNumber() + ': ' + e.getMessage());
}