My original goal was to dynamically enable the SiteFeed feature in a dynamically created publishing sub web. This has been accomplished and works like a charm.
Information on how to do this was found pieced together via these posts: How to enable publishing feature using CSOM? and https://stackoverflow.com/questions/17803291/failing-to-activate-a-feature-using-com-in-sharepoint-2010. Note that the latter filled the gap regarding enabling existing web features using:
this._newWeb.get_features().add(new SP.Guid('15a572c6-e545-4d32-897a-bab6f5846e18'), true, SP.FeatureDefinitionScope.none);
The important bit is that enabling pre-installed web features requires FeatureDefinitionScope.none.
All of this got me to thinking: why not enable a feature deployed via a no-code sandbox solution? Here's my basic code:
var newWebCreationInfo = new SP.WebCreationInformation();
newWebCreationInfo.set_webTemplate('BLANKINTERNET#2');
newWebCreationInfo.set_description('Created Using CSOM');
newWebCreationInfo.set_title(projectSiteTitle);
newWebCreationInfo.set_url(projectSiteUrl);
this._newWeb = this._hostWeb.get_webs().add(newWebCreationInfo);
this._context.load(this._newWeb);
// this._newWeb.set_customMasterUrl(masterPageUrl);
// Activate SiteFeed Feature -- This works totally fine
this._newWeb.get_features().add(new SP.Guid('15a572c6-e545-4d32-897a-bab6f5846e18'), true, SP.FeatureDefinitionScope.none);
// Activate ProjectPortal.NCSS Feature - this fails
this._newWeb.get_features().add(new SP.Guid('d3f51582-abcf-483a-9414-d4976a5094ae'), true, SP.FeatureDefinitionScope.none);
// Do the execution ...
Seems like it should work, right? Problem is, I'm getting the following error:
Request failed. Feature with the id 'd3f51582-abcf-483a-9414-d4976a5094ae' is not installed in this farm, and cannot be accessed to this scope.
The feature is in a SandBoxed solution, and is currently set at the web scope.
Anyone have success doing this?