PublishingWeb.Label is null
-
10-12-2019 - |
Question
I have a feature that activates as soon as a site using my custom web template is created. In that feature, I'm checking if this site is residing within my source label variation hierarchy, so I'm using...
PublishingWeb pubweb = PublishingWeb.GetPublishingWeb(web);
if(pubweb.Label != null && pubweb.Label.IsSource)
{
...
}
But label is null for sites that I create within 'en-us'.
I'm thinking, perhaps the label only has a value if it's the actual rootweb of the label? Or do I have to publish the site and let the variation timer jobs run before I can read the "Label"-property?
Solution
Nevermind, I just found out the problem after some more testing.
I need to let Site propagation job to run before the new site is considered to be a part of the hiearchy and thus having a Label. This means I have to find out a different way to determine if newly created site is a part of the source hierarchy.