Tuesday, December 25, 2018

Culture First Visit issue in SharePoint 2010/2016


SharePoint Pages loaded with incorrect culture on first visit to site. Reproduce issue:
  1. Create a site collection with a language other than the default
  2. Navigate to any site page, Appear with correct culture.
  3. Run IIS Reset.
  4. After and refresh page, It will appear with default culture.
  5. After second refresh, it will appear with correct culture.   
Note: This issue appear with SharePoint 2010/2016.

Solution:
We can use Warm up Script as workaround for this problem:

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;
    $rootFolder.Update();
    $ctx.ExecuteQuery();

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:
https://chayadigital.wordpress.com/2012/07/02/change-the-sharepoint-2010-mobile-view-to-full-site-view-allow-anonymous-users-on-all-mobile-devices/

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://*.outlook.com
• https://*.sharepoint.com
• https://*.microsoftonline.com
• https://*.lync.com


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:

• *.microsoftonline.com
• *.sharepoint.com
• *.outlook.com
• *.lync.com

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();
          m_view.Update();
          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>
  <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>
  -->
  <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" />
  </AggregationCalendar>
</AggregationCalendars>"
}

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.load(this.view);
                 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());
 }