So it really bothers me that it is somewhat difficult to identify the sites that you create based on a template. The answer to that problem is altering the property bag and adding a custom attribute to your web template.

The project has been altered based on the only decent blog post on web templates here: http://blogs.msdn.com/b/vesku/archive/2010/10/14/sharepoint-2010-and-web-templates.aspx and the comments placed here by Vasilli http://sharepoint.stackexchange.com/questions/110446/storing-basetemplateid-and-not-custom-web-template-id

The magic happens by creating a folder (PropertyBag) then creating an empty element inside that folder. Add in your propertybag attribute then create a new feature scoped at Site. Add in your newly created element to that feature and take note of the ID of the feature. Now go back to your onet.xml of your web template and add that feature to the web features section.

Real simple right? We are doing it this way because we are trying to do this without writing any code. The less code the less issues you will have with O365.

With the propertybag values attached to the site, it is now possible to iterate your subsites and find all the sites that used your stunningly beautiful web template.

Random code snippets that gets the properties for a specified site.

var webProperties = hostcontext.getweb().getallProperties();
clientContext.load(webProperties);
clientContext.executeQueryAsync(Function.createDelegate(this, function () { getWebPropertiesSucceeded(webProperties,propertyname); }), Function.createDelegate(this, onQueryFailed));
}

function getWebPropertiesSucceeded(webProperties,propertyname) {

try{
var templatename = webProperties.get_item(propertyname);
console.log(templatename);
}
catch(err)
{
console.log(err.message);
}
}


Last edited Aug 12, 2014 at 1:35 AM by bitterac, version 1

Comments

No comments yet.