Skip to main content

Posts

SharePoint : Update URLs after resotring a content DB of hostnamed site collections

To change or update URLS after resotring a content DB of hostnamed site collections, use stsadm -o renamesite -oldurl http://abc.com -newurl http://abc-uat.com You only need to rename the root hostnamed site collection. It will reflect on the other HNSC starting with the same URL. If you try using Set-SPSiteURL on an HNSC with  same starting url, you will get the error : Could not perform this operation on the site collection http://abc.com. To add a URL for this site collection add a URL to the root host-named site collection at http://abc.com. At line:1 char:1

Correct way to handle exception for Get-SPWeb and Get-SpSite SharePoint PowerShell

Catch block does not work correctly for exceptions from get-spweb and get-spsite without the -ErrorAction Stop parameter.  This code will not print "in catch block"  try{Get-SPWeb 'wrong url'} catch { Write-Host "in catch block" }  correct usage : try{Get-SPWeb 'wrong url' -ErrorAction Stop } catch { Write-Host "in catch block" }

Access Host Web from App web in SharePoint hosted app - Office 365

Here is a snippet to save your day. There are many snippets out there showing you how to do cross domain calls, but none of them complete. Here is a sample to access host web components from a SharePoint hosted app or add in. Keywords: SharePoint, access host web, sharepoint online, JSOM, CSOM, SharePoint hosted app, Office 365. 'use strict'; //URLs var hostweburl; var appweburl; var context; var appContextSite; var factory; var context = SP.ClientContext.get_current(); var appContextSite; var rootweb ; var roleDefinitions ; (function () { $(document).ready(function () { hostweburl = decodeURIComponent(getQueryStringParameter("SPHostUrl")); appweburl = decodeURIComponent(getQueryStringParameter("SPAppWebUrl")); var scriptbase = hostweburl + "/_layouts/15/"; $.getScript(scriptbase + "SP.Runtime.js", function () { $('#message').append(" Getting Scripts.. "); ...