Friday, October 20, 2017

Set Modern Page as a Home Page in SharePoint Online

To Set Modern Page as a Home Page in SharePoint Online you can use the following Code from SharePoint Online PowerShell:

$siteUrl = "Your Site Url"
$password="Your Username"
$username="Your Password"
$WelcomePageUrl ="Welcome Page Url" #SitePages/WelcomePage.aspx

#Add Reference dlls
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Import-Module Sharegate

#Set Connectivity Information
write-host "Connecting to SharePoint "$siteUrl
$pwd =  convertto-securestring $password -asplaintext -force
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) 
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $pwd)
$ctx.Credentials = $credentials

#Set Welcome Page
    $web = $ctx.Web
    $rootFolder = $web.RootFolder; 
    $rootFolder.WelcomePage = $WelcomePageUrl;

Sunday, August 14, 2016

Change the SharePoint Mobile View to Full Site View & Allow Anonymous Users on All Mobile Devices

If you have a public facing site, or just want a consistent branding experience, you can change SharePoint to display the normal site version rather than the mobile compatible version to all browsers.

check url:

This also solve problem of redirect 301 javascript with IPhone

Saturday, February 15, 2014

SharePoint Publish Workflow

I faced problem when deployed SharePoint 2013 site from staging to production.

When added publish workflow to pages in arabic site and start workflow error below occured:

02/09/2014 14:50:44.33    w3wp.exe (0x1610)    0x25D4    SharePoint Foundation    Legacy Workflow Infrastructure    72er    Medium    Microsoft.SharePoint.SPException: تعذر العثور على المستخدم أو مجموعة المجال. ---> System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated.     at System.Security.Principal.NTAccount.Translate(IdentityReferenceCollection sourceAccounts, Type targetType, Boolean forceSuccess)     at System.Security.Principal.NTAccount.Translate(Type targetType)     at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKeyClaim(IClaimsIdentity claimsIdentity, SPClaim loginClaim)     --- End of inner exception stack trace ---     at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKeyClaim(IClaimsIdentity claimsIdentity, SPClaim loginClaim)     at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(String encodedIdentityClaimSuffix)     at Microsoft.SharePoint.Utilities.SPUtility.GetFullUserKeyFromFullName(String fullName)     at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, SPAppPrincipalToken appPrincipalToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)     at Microsoft.SharePoint.SPSite.get_Request()     at Microsoft.SharePoint.SPSite.OpenWeb(Guid gWebId, Int32 mondoHint)     at Microsoft.SharePoint.Workflow.SPWinOEWSSService.GetWebForWorkflow(SPWorkflow wf, SPWorkflowUserContext runAsUser)     at Microsoft.SharePoint.Workflow.SPWinOEWSSService.get_Web()     at Microsoft.SharePoint.Workflow.SPWinOEWSSService.GetWebForListItemService()     at Microsoft.SharePoint.Workflow.SPWinOEWSSService.UpdateModerationStatus(Guid id, Guid listId, SPItemKey itemKey, SPModerationStatusType newModerationStatus, String comments)    ff8d729c-c78b-603d-69e8-3ea7d000f5f3

02/09/2014 14:50:44.35    w3wp.exe (0x1610)    0x25D4    SharePoint Foundation    Legacy Workflow Infrastructure    88xr    Unexpected    WinWF Internal Error, terminating workflow Id# 1cf9fc4b-0227-4ef5-ac6b-4eaef3a50f8e    ff8d729c-c78b-603d-69e8-3ea7d000f5f3

After 3 hours of investigation I found the solution republish Arabic publish workflow.

Map network drive to Offfice 365

If you encounter issues with the mapped drive disconnecting follow these steps

Make sure that you are authenticated to Office 365. To do this, follow these steps:
1. Sign in to the SharePoint Online site by using your Office 365 credentials, and make sure that you click to select the Keep me signed in check box.
2. Open a document library in Explorer View.
3. Try to access the mapped network drive.

If you are authenticated to Office 365 and the issue persists, make sure that an entry for SharePoint is added to the Trusted sites zone in Windows Internet Explorer. To do this, follow these steps:
1. On the Tools menu In Internet Explorer, click Internet options.
2. Click the Security tab, click the Trusted sites zone, and then click Sites.
3. Verify that the following entries are listed in the Websites list:

• https://*
• https://*
• https://*
• https://*

4 If these entries are not present, add them to the Trusted sites list of websites.
5 Click the Local intranet zone, click Sites, and then click Advanced.
6 Verify that the following entries are listed in the Websites list:

• *
• *
• *
• *

7 If these entries are not present, add them to the Local intranet zone list of websites.

Tuesday, October 22, 2013

SharePoint Add Calendar Overlay Programmatically

This is sample of code to add calendar overlay pro grammatically:

using (SPSite site = new SPSite("http://sp2013-tarek294:8000/"))
     using (SPWeb web = site.OpenWeb())
          web.AllowUnsafeUpdates = true;
          SPList list = web.Lists["Calendar"];
          SPView m_view = list.Views["Calendar"];
          m_view.CalendarSettings = SerializeAccessors();
          web.AllowUnsafeUpdates = false;


private static string SerializeAccessors()
 return "<AggregationCalendars>
  <AggregationCalendar Id="{56594c0c-5649-458e-a4e3-939589ddc75d}" Type="SharePoint" Name="Holiday" Description="Holiday" Color="5" AlwaysShow="True" CalendarUrl="/Lists/Calendar/Holiday.aspx">
    <Settings WebUrl="http://sp2013-tarek294:8000" ListId="{6913f374-1a4e-4772-8c5f-9f5d56610f71}" ViewId="{0091da5e-e5a4-4e1f-ab96-19f96eeb59fa}" ListFormUrl="/Lists/Calendar/DispForm.aspx" />
  <AggregationCalendar Id="{d65114d1-cb97-41db-a7eb-7cc3614c957e}" Type="SharePoint" Name="Meeting" Description="Meeting" Color="8" AlwaysShow="True" CalendarUrl="/Lists/Calendar/Meeting.aspx">
    <Settings WebUrl="http://sp2013-tarek294:8000" ListId="{6913f374-1a4e-4772-8c5f-9f5d56610f71}" ViewId="{68513c26-b132-4d9e-b9ca-acc74a4cf1dc}" ListFormUrl="/Lists/Calendar/DispForm.aspx" />
  <AggregationCalendar Id="{cd33c105-6dd4-4cb9-b6ee-ca26dfcdb70e}" Type="SharePoint" Name="TestView" Description="TestView" Color="3" AlwaysShow="True" CalendarUrl="/Lists/Calendar/TestView.aspx">
    <Settings WebUrl="http://sp2013-tarek294:8000" ListId="{6913f374-1a4e-4772-8c5f-9f5d56610f71}" ViewId="{2D81DDC1-A360-4585-BF4A-7C0E512C7AA8}" ListFormUrl="/Lists/Calendar/DispForm.aspx" />

SharePoint 2013 Read Overlay setting using javascript

You can use the following the code to retrieve Calendar Overlay settings using Javascript:

EnsureScriptFunc('sp.js', 'SP.ClientContext', function(){
            var clientContext = new SP.ClientContext.get_current();
            if (clientContext != undefined && clientContext != null) {
                 var web = clientContext.get_web();
                 var listCollection = web.get_lists();
                 var list = listCollection.getByTitle("Calendar");
                 var viewCollection = list.get_views();
                 this.view = viewCollection.getByTitle("Calendar");
                 clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),    Function.createDelegate(this, this.onQueryFailed));
 function onQuerySucceeded() {
        alert(this.view.get_htmlSchemaXml()); //this contains overlays settings
 function onQueryFailed(sender, args) {
       alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

Monday, October 21, 2013

Remove “recent” links from the Left Nav in SharePoint 2013

You can use the following script to master page to remove recent links from Quick launch in SharePoint 2013
jQuery(document).ready(function() {