2

Hello I have to create an entity subscriptions for portal enabled users through my apex

Community community = [ SELECT Id FROM Community WHERE Name = 'Internal Ideas'];
EntitySubscription es = new EntitySubscription();
                        es.NetworkId = community.Id;
                        es.SubscriberId = usr.Id;
                        es.ParentId = oppId;
                        esList.add(es);

but I m ending up with following error

11:41:47:848 USER_DEBUG [97]|DEBUG|Exception***System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Network ID: id value of incorrect type: 09a30000000096rAAA: [NetworkId]

2

CommunityID is different from NetworkID .

You will need to query the Salesforce Network table .

Network networkRec = [Select Id from Network where Name = 'xyz' limit 1];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.