I've two thing for Communities & No-Communities.

1 - To post a Feed to a User in Communities - https://help.salesforce.com/apex/HTViewSolution?id=000187667&language=en_US This works fine for Community User & Non-Community User.

FeedItem post = new FeedItem(ParentId = UserInfo.getUserId(), CreatedById = thanks.GiverId, Body = thanks.Message, RelatedRecordId = thanks.Id, Type = 'RypplePost');

        String networkId = Network.getNetworkId();
        if(networkId != null) {
            post.NetworkScope = networkId;

        insert post;

This works fine in Communities, but breaks when Communities are not enabled. If I comment out 'post.NetworkScope = networkId;' - the package installs fine, if not I get the Installation Error as below:

2 - Images in Community How to include images from static resources in lightning components used in communities?

String networkId = Network.getNetworkId();

if(networkId != null) {
 List<Network> networks = [ Select UrlPathPrefix from Network where Id = :networkId ];
 if(networks.size() > 0) {
   return '/' + networks[0].UrlPathPrefix;
return '';

I'm appending that UrlPathPrefix to the Images on communities when UrlPathPrefix != ''. I think Select UrlPathPrefix from Network where Id = :networkId is causing the below error.

  1. Missing Organization Feature: Networks null

  2. Missing Organization Feature: NetworksEnabledOnce null


1 Answer 1


I think the issue is because even to use Network class ,the Network Object should be available in the org .Also it depends if your class is using with sharing or without sharing .

With sharing means the package installation context will obey the installing user privileges else it will be a ghost user .

You can follow below methodology to make sure communities is enabled for all community related logic

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); 
   system.debug('Communities is enabled!');
  return true;
  system.debug('Communities is disabled!');
  return false;
  • Thanks for the answer, but No, it did not work :( Missing Organization Feature: NetworksEnabledOnce Jul 29, 2016 at 5:12
  • List<Network> networks = [ Select UrlPathPrefix from Network where Id = :networkId ]; Gives this error: sObject type 'Network' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names. Jul 29, 2016 at 5:17
  • post.NetworkScope = Network.getNetworkId(); - Gives this error : Missing Organization Feature: Networks Jul 29, 2016 at 6:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .