How it works: Site categories form for subsite creation

This post is part of the Site directory troubleshooting series, you can access the other posts here.

So the focus is on the rendering and submit action of this form on the /_layouts/newsbweb.aspx page.

sitedir6

This is the pre-requisite check process for the form rendering:

  1. Get the relative path of the site directory subsite to be used
    1. Check if there is a query string parameter called sitedirectory passed in containing the url encoded relative url of the site directory subweb in this site collection.
    2. If the query string is specified SharePoint returns with the urldecoded string passed in. If this url not specified in the query string or it is empty then SharePoint checks the rootweb of the site collection otherwise .  It looks for the SiteId and the WebId in the rootweb’s AllProperties bag. The actual keys are these DefaultSiteDirectorySiteId and DefaultSiteDirectoryWebId.
    3. Then the site and subweb is opened using the ids retrieved. Access denied and File not found exceptions are handled silently and empty string is returned for site directory url.
    4. If the web can be opened using the current user’s credentials SharePoint looks up the SiteDirectoryList. The first list with template type == 300 will be returned.
    5. Then SharePoint checks if the current user has the following rights on that list AddListItems, EditListItems, ViewListItems. (This check was introduced in 2008 December MOSS rollup and also included in MOSS Service Pack 2 and this check is not applied when query string contains the url due to step 2)
    6. If all checks succeed the relative url of the site directory subweb is returned otherwise empty string.
  2. If the returned url is not null the form is displayed.
  3. SharePoint checks in the rootweb’s AllProperties bag is the enforcement has been turned on with the EnforceNewListingForSites property and displays the checkbox accordingly.
  4. Same action to retrieve the entry requirements to decide if the user needs to specify value to all controls or only one.
  5. Open the subweb with url retrieved in step 1.
  6. Try to get the list, if the list cannot be retrieved (not exists, or read access denied) the following line is logged into ULS if the Site Directory trace level is High or above:
    ”CreateSitePanel: Site directory list was not found in the web:“
  7. In order to retrieve the View which specifies the fields to be displayed in the form SharePoint looks up the name of the view from core resource using the language of the site directory web.  The name of the view is localized, in English it is called “Site Creation Categories” - “Capture.aspx”.
  8. Then SharePoint enumerates the ViewFields property of the View and renders the control for the corresponding field type
    1. For Choice column it will be a DropDownList with the choices of the field.
    2. For MultiChoice it will be a checkbox list with the choices of the field.
    3. For Lookup field it will be a DropDownList with the values of the lookup list items.
    4. For Boolean field it will be a checkbox.
    5. For all other types it will be a simple textbox.
  9. If there is any problem encountered during the Form field rendering the following line is logged into ULS if the Site Directory trace level is Medium or above:
    ”CreateSitePanel1: An exception occured creating child controls. Setting CreateSitePanel1 to not render. Exception: “

Note: there is a typo in the ULS log entry itself, I pasted as you will see it in the log.

On submit event depending on the entry requirements server side validation runs to check all field values or to ensure that at least one is filled out.

Then a new list item is created in the site directory list in the site directory subweb with the new subweb’s title, description, url and the selected values of the form fields.

If there is an error during save the following line is logged into ULS if the Site Directory trace level is High or above
”CreateSitePanel1: An exception occured in OnFormSave(). Exception:”

Note: there is a typo in the ULS log entry itself, I pasted as you will see it in the log.

Troubleshooting

If the form is not displayed on /_layouts/newsbweb.aspx

  • Verify Site directory settings on the top level website in Site actions / Site settings / Site directory settings. Enter the relative url of the site directory subsite. The settings page does not give an error if the entered subweb was not created with the Site directory template so you have to open it again to verify if the path is not empty. If it is empty than the subweb you entered is not a valid site directory subsite.
  • Verify the subweb in the sitedirectory  query string parameter if there is any in the browser’s address bar, try to remove the sitedirectory= section with the url value and try again to see if the local site directory web can be determined automatically.
  • To easily verify the necessary user rights and possibly missing list or view ensure that you add the sitedirectory  query string parameter with your site directory’s relative web as value and enable the Site Directory ULS category with Verbose trace level. You can find the cause of your form display issue with the ULS log entries.
  • Verify the rootweb’s property bag looking for the site directory properties
  • Check the existence of the Sites list and the Capture.aspx view in it (“Site Creation Categories” in English, for other languages you can check \12\resources\spscore.*.resx , it’s resource label is called SitesList_CaptureViewName_Text). A view with this localized name must exists otherwise the form rendering will fail.

You can use the following powershell script to validate the root web’s property bag:

[Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")

$sitecollurl = "https://bobmoss32:9000";
$site = new-object Microsoft.SharePoint.SPSite($sitecollurl);

$web = $site.OpenWeb();

# Display all properties in a table

$web.AllProperties | ft

#Fetch the critical properties and check them

$strwebguid= $web.AllProperties["DefaultSiteDirectoryWebId"]
$strsiteguid= $web.AllProperties["DefaultSiteDirectorySiteId"]
if ($site.ID.toString("D") -ne $strsiteguid) {"Error: SiteID does not match current site's ID. Save site directory settings in site actions to fix it."}

# Verify subweb’s existence by its ID

"Checking subweb with ID:" + $strwebguid

$sitedirguid = new-object Guid($strwebguid)
$sdirweb = $site.OpenWeb($sitedirguid);
$sdirweb.Url

# if a valid web can be opened and url is returned then the property bag looks ok.

 

  • There is a specific scenario when a user can receive Access denied for the whole create subweb page – this is connected to a problem how site directory checks the rootweb’s properties. Scenario: a subsite owner whose subsite has unique assigned permissions and this owner has no rights on the root of the site collection wants to create a sub-subsite under his site and site directory is configured for tis site collection. In this case during the rootweb’s property bag check the user gets an access denied. This problem has been corrected in the MOSS 2008 December rollup. The fix for this is also included in MOSS Service Pack 2. After the fix the site directory form will not be displayed for such user due to permission issues but subsite creation will work.

 

Form submit fails and subsite is not added to the list.

  • Check ULS for the exception during list item addition.
  • Try to open the site directory list and add an item manually using the user to verify if you receive an error. Try to resolve the error received.

For the site collection form rendering and troubleshooting read the post here.

Back to the table of contents