SharePoint, Office 365, Azure, and Front end JS geek. – Chicago IL
SharePoint, Office 365, Azure, and Front end JS geek. – Chicago IL

SharePoint

Clone Content Database – SQL Copy + Generate SPSite GUID

Tried of waiting for Backup-SPSite / Restore-SPSite?  Me too.  Why not clone the SQL content database with SQL backup and restore?  

 

Well, SharePoint requires every Site Collection on a given to have a unique GUID.  When we clone a SQL content database and attempt Mount-SPContentDatabase an error comes up that the GUID already exists on the local farm.  No bueno.

Why not generate and replace the GUID?   In theory, we can UDPATE the SQL database internally with fresh new GUID numbers and SharePoint would recognize as new site collections.  No conflict.  That is exactly what the PowerShell below does.  By walking the schema, finding “SiteID” and “tp_SiteID” columns, and replacing the old GUID with a new GUID.

The larger the site collection, the better this works on time savings.  SQL internally can backup and restore a database much faster than waiting for Backup-SPSite/Restore-SPSite to export/import binary data across the wire to the SharePoint front end file system.

In the example below you can see a brand new team site created with GUID “82dad5a8-aa6e-4480-a10e-16cd2597c18b” in a dedicated SQL content database, taken offline, updated with PowerShell to replace old GUID with new GUID “0f59c302-92ea-4fac-b32b-799f3dd41264” and then successfully consumed again.

 

  • NOTE – You still need a unique URL, so be sure to run Mount-SPContentDatabase against a secondary web application.
  • NOTE – This is completely unsupported.  Use at your own risk.   Worked well on Dev and Test environments for me.

 

PowerShell Source Code

 

Context Diagram

image

Screenshots

image
image
image
image
image
image
image
image
image

 

 

References

SharePoint as a Service (SPaaS)

SharePoint is often treated as a final SAAS product to perform Microsoft native functions only.  Management can be reluctant to engage customization and development for the perceived cost. 

However, what is the cost of lacking a needed business tool?  Lost productivity and opportunity?  

What is the cost to create native SP features?   Make a blank IIS website?  Then create your own search, audit, permission interface, file store, REST endpoint, etc.?

 

Today is the best time ever to be a developer.  Many services and many tools.   Agile design can be applied to leverage 90% native platform with 10% custom code to spin up helpful business applications with low cost.   Micro services, REST api, and JavaScript frameworks provide the building blocks.   Developers are challenged to learn these new tools.  Ones that do can help deliver business value faster than ever.

 

Remember, SharePoint is a service– not the final product. 

shades_smile

 

Features

  • Authentication – User context.  Password management, new account creation, integrated single sign-on.
  • Permissions – Groups, roles, custom permission levels,
  • Tables & Files – Storage of flat database (rows, columns, validated input, query) and binary files (folder, files)
  • Notification – Alert on data changes.  Daily and weekly summary.  Custom email body with Workflow.
  • Search – Index content, word parsing, custom results display, full REST api.
  • Audit – Regulatory compliance.  Reports, export, filter, and granular detail.
  • … and many more

 

Diagram

image

 

References

Custom Web Part – Save settings to SPList (without jQuery)

Ever wanted to code a JavaScript content editor (script editor) web part that saves settings to a list?   Without jQuery?

The library below “wp-settings.js” does exactly that with native XHR (XML HTTP Request) and nested callback to invoke REST API.   The free standing POJO (Plan Old JavaScript Object) design enables us to package into a web part gallery and use freely across any site without preparation work to ensure jQuery, Angular, or other dependent frameworks are loaded.

Look at the “webpart.html” to see example usage pattern:

  • wpsRead()  Get settings (if any)
  • wpInit()  Local web part initialize
  • wpsWrite()  Save settings (UPDATE/INSERT)

 

Cheers! 

shades_smile

 

 

Source Code

 

Video

 

Screenshots

image
image
image

 

References

SPAuditAPI – Read SharePoint audit logs from JavaScript over REST

Recently I wanted to query Audit data from the web browser client and learned no native REST api was available.   So I created one.   Below is a demonstration video and link to the full source code.

This web API enables us to execute the server object model SPAuditQuery() method from HTTP POST and provide optional filter parameters.   More filters give a narrow match and faster server response.   We want to be specific, even if only a default time range (example – past 30 days) to improve user experience and reduce system load.

Cheers! 

shades_smile

 

 

Source Code

 

Video

 

Context Diagram

image

 

Screen Shots

image
image
image

image

© Copyright 2016
@ SPJeff

Return to Top ▲Return to Top ▲