SharePoint Experts, Information Architects, Expert Witness

We provide consulting in a broad array of business and technology from architecture to design to deployment of global systems with a focus on surfacing data in the enterprise. Specialists in Microsoft, we are a premier provider of SharePoint Expertise (including 2016 and Office 365). We also provide Expert Witness/Legal Expert in eDiscovery, source discovery, patent infringement, piracy and more! We also have established SICG DLDS s.a. - our counterpart in Costa Rica that specializes in water systems (http://www.crwatersolutions.com) - Contact me direct: david_sterling@sterling-consulting.com or call 704-873-8846 x704.

Search This Blog

Saturday, April 15, 2017

Getting the Web ID for a site (SharePoint & Online)

There's often a need to find the Web ID of a SharePoint site - specifically when exporting web parts (as shown in this article https://chuvash.eu/2014/09/19/export-any-web-part-from-a-sharepoint-page/).

NOTE: I don't take credit for these, these are a summary of what's out there!

So getting the ID can be done a number of ways - first, using the "API" (if using SharePoint Online, authenticate to the site first):

https://<site>/_api/web/id

For Online:

https://<site>.SharePoint.com/_api/web/id

subsite:

https://<site>.sharepoint.com/sites/subsitecoll/_api/web/id

Next using on premise PowerShell:

$site = Get-SPSite  http://<site & port>
$web = $site.AllWebs["<name of site>"]
$web.ID

In SharePoint Online using the SharePoint Online Management Shell:

Connect-SPOService -URL https://<org>-admin.sharepoint.com

Enter your credentials, then enter:

Get-SPOSite -Identity https://<site>.SharePoint.com
Next connect to the site:

Connect-SPOSite -Url "https://<site>.sharepoint.com/" -Credential "<someone@org.com>"

If you omit -Credential, you will be prompted (the credential is your EMAIL address <someone@org.com>, not the AD account domain\account) but better to use this:

$username = "<someone@org.com>"
$password = "<password>"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(ConvertTo-SecureString $password -AsPlainText -Force)
Connect-SPOSite -Url "https://<site>.sharepoint.com/" -Credential $cred


Then finally for the top level web:

Get-SPOWeb -Identity "/"

For a subsite, use the name:

Get-SPOWeb -Identity "News"

Get-SPOWeb will list out details of the web - just look for the "Id" column.

Note - if using a Subsite under /Sites/, you have to connect to that site collection (instead of https://<site>.SharePoint.com, you use https://<site>.SharePoint.com/sites/subcollection".

Another way is through the URL. Open the site/web you want and open Site Settings. Click either the Site Content and Structure or Content and Structure Logs link. Click on the web in question and select the drop down then select General Settings - cut and paste the URL into notepad - you will find the ID in the query string after SPWeb (%3A = : - see here http://www.degraeve.com/reference/urlencoding.php). Here's snip of the URL where the SPWeb can be found:

FSmtContext%3DArea%3A%3FSPWeb%3A1b43b8ac-973e-4291-a268-fc9c0ecb4eb3%3A%26SmtContextExpanded%


Yet another is using jQuery - found on the MSDN site: 

<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script><script type="text/javascript">
function GetSPWebID()
{
        url = document.getElementById("field1").value;
        var webId;
  
 var soapEnv =
    "<?xml version='1.0' encoding='utf-8'?>\
  <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>\
    <soap:Body>\
    <GetWeb xmlns='http://schemas.microsoft.com/sharepoint/soap/'>\
    </GetWeb>\
    </soap:Body>\
    </soap:Envelope>";
  $.ajax({
      url: url + "/_vti_bin/SiteData.asmx",
      beforeSend: function(xhr) {xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetWeb");},
      type: "POST",
      data: soapEnv,
      dataType: "xml",
      async: false,
      complete: function(xData, status) {webId = $(xData.responseXML).find('WebID').text();},
      contentType: "text/xml; charset='utf-8'"
    });
 document.getElementById("field2").value=webId;
}</script>Root Web URL: <input id="field1"/><br/>WebID: <input id="field2"/> <br/><br/><button onclick="GetSPWebID()">Get Web ID</button> 
//nonsense comment to keep IE7 from truncating MSDN code

 

SharePoint Online Workflows not working


Having had this problem and forgetting what I did to fix it, I did another search to find the answer so posting it here.

The issue is that though workflows publish correctly (i.e. no errors), they still do not fire (not sending email, not logging, etc.). In SharePoint Online, it turns out that a feature that SHOULD be enabled is not.

When this happens to you, navigate to the site where you are adding the workflow, click the Gear then select Site Settings. Find the Site Features (under Site Settings). Scroll to the bottom of the page and find the feature "Workflows can use app permissions" and activate it:

 

Wednesday, April 5, 2017

The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request

While I know Sandbox Solutions are going bye-bye, there are many on premise solutions where they are handy. However as some of you may have encountered, there are times when the error:

The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request

appears. There is a common post on this by Ricky Kirkham:

http://blogs.msdn.microsoft.com/sharepointdev/2011/02/08/error-the-sandboxed-code-execution-request-was-refused-because-the-sandboxed-code-host-service-was-too-busy-to-handle-the-request-ricky-kirkham/

Having encountered this issue recently, I tried following his instructions to no avail. None of the solutions there worked. However I did come across another one that did:

http://stackoverflow.com/questions/12293469/the-sandboxed-code-execution-request-was-refused-because-the-sandboxed-code-host

This solution is shown as follows:

$uc = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
$uc.WorkerProcessExecutionTimeout = 5000
$uc.Update()
$tier = $uc.Tiers[""]   # default Tier has no Name
$tier.MaximumWorkerProcesses = 2    # number of CPU Cores + 1
$tier.Update()

By default, the Timeout is set to 30 and the Worker Processes set to 1. The above obviously changes 30 to 5000 (5000 seems a little excessive if you ask me) and the number of processes to be Cores + 1 (i.e. 4 Core Machine = 5).

This does indeed fix the problem! However, on my 8 Core machine, I thought that 9 was a bit much (might impact performance) so I set it at 2500/4 and it still worked.

To check your current settings, do the following in the Command Shell:

$uc = [Microsoft.SharePoint.Administration.SPUserCodeService]::Local
$tier = $uc.Tiers[""]   # default Tier has no Name
$timeOut = $uc.WorkerProcessExecutionTimeout 
$timeOut
$mWProc = $tier.MaximumWorkerProcesses
$mWProc

FYI: If you apply changes you MUST Stop and Restart the Sandbox service through Central Admin - a reboot will also fix if you are not in production.