Interactive JavaScript Maps Integration with SharePoint 2013 using Script Editor Web Part

4. March 2015 03:23 by Rashid Aziz in Sharepoint blogs  //  Tags: ,   //   Comments
I have a top level SharePoint site called “Our Offices” and sub site for each country office location (e.g. London, Berlin etc.). The “Our Offices” site home page needs to provide easy navigation to all offices sub sites. Also, I wanted to show where this office location reside on the world map and when someone click on the location, system should redirect the user to that location site home page.  To do this I have used AmMap solution. The JavaScript / HTML5 mapping library (jsmap) help to create interactive, animated maps and display them in your web sites or web applications. Navigate to and click on download button.    On the next page, click “Interactive JavaScript Maps” download link as highlighted below.  Once downloaded, extract the zip folder and give the root folder a proper name.  (By default it will be something like “”. I have renamed the root folder to “CoolMaps”) Copy the “CoolMaps” folder, Navigate to SharePoint 15 hive Layouts folder (C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS) and past the “CoolMaps” folder here. Add “Script Editor” web part on “Our Offices” site home page.    Copy and paste the following code into your script editor web part. Note: Please updated the locations and SharePoint sub site URLs as per your business requirements. <link rel="stylesheet" href="/_layouts/15/CoolMaps/ammap/ammap.css" type="text/css"> <script src="/_layouts/15/CoolMaps/ammap/ammap.js" type="text/javascript"></script> <!-- map file should be included after ammap.js --> <script src="/_layouts/15/CoolMaps/ammap/maps/js/worldLow.js" type="text/javascript"></script> <script type="text/javascript"> var map; // svg path for target icon var targetSVG = "M9,0C4.029,0,0,4.029,0,9s4.029,9,9,9s9-4.029,9-9S13.971,0,9,0z M9,15.93 c-3.83,0-6.93-3.1-6.93-6.93S5.17,2.07,9,2.07s6.93,3.1,6.93,6.93S12.83,15.93,9,15.93 M12.5,9c0,1.933-1.567,3.5-3.5,3.5S5.5,10.933,5.5,9S7.067,5.5,9,5.5 S12.5,7.067,12.5,9z"; AmCharts.ready(function() { map = new AmCharts.AmMap(); map.pathToImages = "/_layouts/15/CoolMaps/ammap/images/"; map.imagesSettings = { rollOverColor: "#FFA02F", rollOverScale: 3, selectedScale: 3, selectedColor: "#FE5815", color: "#FE5815" }; var dataProvider = { mapVar: AmCharts.maps.worldLow, images: [ {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"London", latitude:51.5002, longitude:-0.1262, url: "../London"}, {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"Paris", latitude:48.8567, longitude:2.3510, url: "../Paris"}, {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"Berlin", latitude:52.5235, longitude:13.4115, url: "../Berlin"}, {svgPath:targetSVG, zoomLevel:5, scale:0.5, title:"Amsterdam", latitude:52.3738, longitude:4.8910, url: "../Amsterdam"}, {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"Singapore", latitude:1.2894, longitude:103.8500, url: "../Singapore"}, {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"Islamabad", latitude:33.6751, longitude:73.0946, url: "../Islamabad"}, {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"Beijing", latitude:39.904030, longitude:116.40752599, url: "../Beijing"}, {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"Tokyo", latitude:35.6785, longitude:139.6823, url: "../Tokyo"}, {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"Chicago", latitude:41.87811360, longitude:-87.6297981999, url: "../Chicago"}, {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"Bucharest", latitude:44.4479, longitude:26.0979, url: "../Bucharest"}, {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"Moscow", latitude:55.7558, longitude:37.6176, url: "../Moscow"}, {svgPath:targetSVG, zoomLevel:5, scale:1.0, title:"San Marino", latitude:43.9424, longitude:12.4578, url: "../SanMarino"} ] }; map.dataProvider = dataProvider; map.objectList = new AmCharts.ObjectList("listdiv"); map.showImagesInList = true; map.write("mapdiv"); }); </script> <div> <div id="listdiv" style="width:200px; overflow:auto; height:500px; float:right; background-color:#FFFFFF;"></div> <div id="mapdiv" style="margin-right:200px; background-color:#FFFFFF; height: 500px;"></div> </div> <br/>   Save the page and publish it.  The Map should appear like this on the page   On mouse hover it will highlight the location on the map and when user click on a location, it will take you to pre-configured sub site for that location.  The map I am showing here is just for demo purpose. There are many more types of maps available in this library. Go and explore the rest 

Customise SharePoint 2013 Blog site template

20. January 2013 11:51 by Rashid Aziz in Sharepoint blogs  //  Tags: ,   //   Comments
You can find the OOTB onet.xml of blog site template at the following location C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\SiteTemplates\Blog I was surprised that there is not any default.aspx page for this blog template which was available in SharePoint 2010. The OOTB SharePoint 2013 blog site template folder has missing default home page. I have imported the Onet.xml file in visual studio; it contains the following web features. <WebFeatures>         <!-- TeamCollab Feature -->         <FeatureID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5" />         <!-- MobilityRedirect -->         <FeatureID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4" />         <!-- Blog feature -->         <FeatureID="FAF00902-6BAB-4583-BD02-84DB191801D8" />         <!-- MDS -->         <FeatureID="87294C72-F260-42f3-A41B-981A2FFCE37A" /> </WebFeatures> After few minutes I realised that there is a feature in 15 hive which called “Blog Home Page”. You can find the “Blog home page” feature.xml at the following location C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES You need to reference this feature in blog site definition to make sure that when a user create site based on your custom blog template, it activates this feature which create home page for blog site. The resulting Web feature node in blog onet.xml will look like this <WebFeatures>         <!-- TeamCollab Feature -->         <FeatureID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5" />         <!-- MobilityRedirect -->         <FeatureID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4" />         <!-- Blog feature -->         <FeatureID="FAF00902-6BAB-4583-BD02-84DB191801D8" />         <!-- MDS -->         <FeatureID="87294C72-F260-42f3-A41B-981A2FFCE37A" />        <!-- Blog Home Page feature -->        <FeatureID="E4639BB7-6E95-4E2F-B562-03B832DD4793"/>  </WebFeatures>

Programmatically show processing screen in SharePoint 2010

25. May 2012 08:45 by Rashid Aziz in Sharepoint blogs  //  Tags: ,   //   Comments
Some time when writing a custom solution in SharePoint which takes some time to process, it is nice to show end user some message screen saying something like “Please wait we are dealing with your request”. In SharePoint 2010 this functionality is available out of the box, we can call SPLongOperation class in code and display the below screen with custom message and also can redirect to a different page after completion. // Initialise SPLongOperation object and specify message you want end users to see. SPLongOperation lp = new SPLongOperation(this.Page); lp.LeadingHTML = "<div><h2>Processing Request</h2></div>"; lp.TrailingHTML = "<div><h3>Please wait, your request is being processed</h3></div>"; lp.Begin(); // long running code start  // long running code end lp.End(Customers.DefaultViewUrl, Microsoft.SharePoint.Utilities.SPRedirectFlags.Default, this.Context, ""); I hope this will help.

Get SharePoint Webpart Usage Report

  During an extranet migration to office 365 we need to find out a custom content editor webpart usage.  That web part was used in many location that I would be waste of time to find all the references. I decided to write a query again extranet site content database to find out webpart usage. The first thing we need is the “Webpart type ID”. Download this tool from  and follow the instruction  to retrieve webpart type ID. Now open SQL management studio and run the below query against SharePoint site content database. Note:  Make sure that you have replaced the 'Webpart type ID here' with the right 32 digit webpart type id in the below query before you run it. SELECT DISTINCT D.SiteID, D.WebId, W.FullURL as WebURL, D.Id As DocumentId, D.DirName, D.LeafName, tp_ID As WebPartSK FROM       dbo.Docs D WITH (nolock)  INNER JOIN dbo.Webs W WITH (nolock) ON D.WebID = W.Id INNER JOIN dbo.WebParts WP WITH (nolock) ON D.Id = WP.tp_PageUrlID WHERE WP.tp_ListId Is Null AND WP.tp_Type Is Null AND WP.tp_Flags Is Null AND WP.tp_BaseViewID Is Null AND WP.tp_DisplayName Is Null  AND WP.tp_Version Is Null AND WP.tp_WebPartTypeId='Webpart type ID here' Run the query and you will see the result table with all webpart references. If you have multiple content databases then you can run this query against each of them to find all webpart references.  

SharePoint 2010 time zones setting programmatically

11. April 2012 04:00 by Rashid Aziz in Sharepoint blogs  //  Tags: , ,   //   Comments
The SharePoint 2010 server is always set to a specific time zone. Users from all over the world can change the time zone by using “My regional settings”. I wanted to achieve this programmatically as a batch operation. To do this, I have used the following code. SPRegionalsettings spRegnal= new SPRegionalSettings(web, true); spRegnal.TimeZone.ID = 2 ;     // Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London User.RegionalSettings= spRegnal ; The SPRegionalSettings takes two parameters, the SPWeb and a Boolean. Set the time zone ID and finally get the SPUser object and assign the regional settings to that user.  

SharePoint 2010 rich text editing tool styles

I came across a scenario where my client wants SharePoint extranet site contents look and feel consistent. The site have many sub sites and which lot of publishing pages, editors can create pages, add content editor web part and add contents. The request routed to me about deleting some custom styles from content editing tool and adding some new ones. Solution Open the current “Master” page in SharePoint 2010 designer. Click “Style” tab from designer menu and select “Manage styles” Right click any CSS style from” Manager Style” list  and select “Go to code” The core CSS file has all styling references ; the style starts with name “.ms-rteStyle”. Create new styles as .ms-rteStyle-stylename {-ms-name:"Eblogin Style"; color:#00adee;} Save the Core.css file Note: YOU CAN ALSO DELETE THE EXISTING STYLES BEFORE SAVING THE CSS FILE Open the SharePoint site and go to a page which has content editor web part. Edit any content inside the content editor web part and try to select the style from editing tool. You will see new style as shown below

Add all authenticated users to sharepoint security group programmatically

One of the projects I came across a scenario where I need to pre populate custom security groups with “All authenticated Users”. I have wrote a code and run it as a part of the feature receiver. If you have a security group with read access to a site collection, you can add “All authenticated users” into this groups and every user will have read access to that site. In the feature receiver class FeatureActivated event I have used the following code. SPWeb myWeb = properties.Parent as SPWeb; permissionLevel = "Read"; myWeb.SiteGroups.Add("Site Read Group", owner, owner, "My New Category"); SPRoleAssignment roleAssignment = new SPRoleAssignment(myWeb.SiteGroups["Site Read Group"]); roleAssignment.RoleDefinitionBindings.Add(myWeb.RoleDefinitions[permissionLevel]); myWeb.RoleAssignments.Add(roleAssignment); myWeb.Update(); myWeb.SiteGroups["Site Read Group "].AddUser("c:0(.s|true", string.Empty, string.Empty, string.Empty); Note: The "c:0(.s|true" means “All Authenticated Users”

Use PowerShell to set security timeout in SharePoint

A user logged off after a certain period of time from sharepoint 2010 site. You can reset this timeout according to your requirement.  If you need a user session to be open for more time you can always change the security time out by using PowerShell. Open PowerShell management console and copy past the following code. Note: change the session Time span according to your need. In this code it is setup as 1 hour and 20 minutes. $SPSite = Get-SPSite("[URL of site collection]") $webApp = $SPSite.WebApplication $webApp.FormDigestSettings.Enabled = $true $webApp.FormDigestSettings.Expires = $true $webApp.FormDigestSettings.Timeout = New-TimeSpan -Hours 1 -Minutes 20 $webApp.Update() Now it will enable the session expiry time to 1 hour and 20 minutes for this site collection.

SharePoint blog with attachment capability workaround

24. November 2011 07:29 by Rashid Aziz in Sharepoint blogs  //  Tags: , ,   //   Comments
By default there are not any settings in sharepoint to enable attachments with blog posts. It is not a perfect way to do this, but worth to mention on my blog I think. I have done a workaround to achieve this Create a custom list inherited form Item with default columns. Create new item “give it a title” and attach your document with it. Now in your post list create a lookup column with the title “Attachment” which will look up to the “Title” column of your custom list. Edit the view of you posts web part on the blog main page and enable it to display the lookup field. You can now see the attachment in the footer. I hope this blogs helps J

Custom master page deployment in SharePoint 2010

20. May 2011 02:52 by Rashid Aziz in Sharepoint blogs  //  Tags: ,   //   Comments
Today I am going to show you that how easily you can deploy your custom master page as a SharePoint feature and it automatically change the site default master page when you activate this feature. For this you need to create new empty SharePoint project. Add a new item to the project and select module and call is “Module1”. Once the module is created it contains “element.xml” and “sample.txt” file, rename the “sample.txt” file to “customMaster.master” as shown in below image.               Now you can copy code from your custom master page which you want to deploy(If you don’t have your custom code then you can use SharePoint 2010 designer and copy the contents of v4.master and past them in your customMaster.master file in Visual Studio. Make the changes you want to. Copy the following code and replace your “element.xml” file. <?xmlversion="1.0" encoding="utf-8"?> <Elementsxmlns="">   <ModuleName="Module1" Url="_catalogs/masterpage">     <FilePath="Module1\customMaster.master" Url="customMaster.master" />   </Module> </Elements> Now you have to add feature event receiver, so on feature activation this custom master page will be your default master page. To do this, right click on your feature1 and select “Add event receiver” Replace the “FeatureActivated” and “featureDeactivating” method with the followings public override void FeatureActivated(SPFeatureReceiverProperties properties)         {             SPSite site = (SPSite)properties.Feature.Parent;             SPWeb web = site.RootWeb;             Uri masterUri = new Uri(web.Url + "/_catalogs/masterpage/custommaster.master");             web.MasterUrl = masterUri.AbsolutePath;             web.CustomMasterUrl = masterUri.AbsolutePath;             web.Update();         }  public override void FeatureDeactivating(SPFeatureReceiverProperties properties)         {             SPSite site = (SPSite)properties.Feature.Parent;             SPWeb web = site.RootWeb;             Uri masterUri = new Uri(web.Url + "/_catalogs/masterpage/v4.master");             web.MasterUrl = masterUri.AbsolutePath;             web.CustomMasterUrl = masterUri.AbsolutePath;             web.Update();         } Now deploy the feature, when you will activate the feature it will replace you default master page with “customMaster.master” , and when you deactivatethe feature it will replace  to default master page which is V4.master.

Stay connected

SharePoint Links

Month List