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());
 }

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() {
 jQuery(".ms-core-listMenu-item:contains('Recent')").parent().hide();
});

Friday, October 11, 2013

SharePoint Impersonation mistake

SharePoint API give us function  SPSecurity.RunWithElevatedPrivileges to impersonate by system account users. Some users make mistake in using it by using current site instead of initiate new SPSite.:

SPSecurity.RunWithElevatedPrivileges(() =>
{

using ( SPSite site = SPContext.Current.Site)
{
using (SPWeb web = site.OpenWeb())
{
....................
}
}
}
});

Developer need to use:
SPSite site = new SPSite(SPContext.Current.Site.Url)

instead of:
SPSite site = SPContext.Current.Site

Code will be:
SPSecurity.RunWithElevatedPrivileges(() =>
{

using ( SPSite site = new SPSite(SPContext.Current.Site.Url) )
{
using (SPWeb web = site.OpenWeb())
{
....................
}
}
}
});

Thursday, September 19, 2013

Enable Validator in Email in arabic DisplayName


To Create formula validation for fields in arabic display name you needto replace all commas ',' with semicolons ';'

Check below Email Formula validation  for Arabic field:

=AND(ISERROR(FIND(" ";[البريد الالكترونى];1));IF(ISERROR(FIND("@";[البريد الالكترونى];2));FALSE;AND(ISERROR(FIND("@";[البريد الالكترونى];FIND("@";[البريد

الالكترونى];2)+1));IF(ISERROR(FIND(".";[البريد الالكترونى];FIND("@";[البريد الالكترونى];2)+2));FALSE;FIND(".";[البريد الالكترونى];FIND("@";[البريد الالكترونى];2)+2)
الالكترونى])))))

Safari Browser does not run videos in Asset Library

When used Safari browsers and tried to access videos in asset library, I found black block.
I know Safari supports Html 5 and can run Video tag. After some investigation I found article describe the problem, Safari needs to install quick time to run video using Video tag for more details check Url:

http://eugenekardash.blogspot.com/2012/09/video-in-html5-no-support-in-safari.html

Thursday, August 29, 2013

Move Search Components To Different Server in SharePoint 2013 Problem


I want to move search components from front end server to separate server, I used the flowing url:
http://altfo.wordpress.com/2013/04/19/move-search-components-to-different-server-in-sharepoint-2013/

After doing the following steps and checked search components, I found only crawled components moved successfully and others are suspended.

After investigations I remembered,  We did memory limitations for Fixing Performance Issue Caused By Node Runner In SharePoint 2013.
Memory limitations prevent creation of new search components successfully. I removed memory limitation and success to move search components.



Friday, August 16, 2013

SharePoint Migration Utilities

When I Migrated or revamped SharePoint I need to do some tasks help migrate old items, alerts, etc with new structure. I wroted some utilities to do these tasks using SharePoint API. I know there is many tools can do these tasks but here will find free utilities to do simple tasks.
Copy Files
Copy list Document libraries  and mapped old properties to new properties.

Copy Alerts
Copy Alerts from source web to destination Web

Copy Images
Copy Images from source image library to destination image library

Copy List Items
Copy List Items from source list to destination list

Copy Pages with resources
Copy Publish Pages between source and destination, Update layouts, clean HTML

Copy SharePoint Security
Copy Security between source and destination list.

Jungle.SharePoint.Util
Utilities help in migration tasks






Thursday, May 16, 2013

Reduce the size of logging database

To reduce the size of the logging database or to purge the old data from the logging database we can these steps:
By Default the system retains 14 days of Usage data in this database. You need to decrease value of the retention days by the following PowerShell Command:
Set-SPUsageDefinition –Identity "Event Selection" -DaysRetained days
Example:
Set-SPUsageDefinition –Identity “Page Requests" -DaysRetained 3
You can get values of retention days by the following command
Get-spusagedefinition
After that we need to run the two timer jobs to clean the old data, Go to Job Definitions and Run the following Jobs:
  • Microsoft SharePoint Foundation Usage Data Import
  • Microsoft SharePoint Foundation Usage Data Processing
Once the timer jobs is run you can check and confirm database has released the space.

Failed to unlock sitecollection

For some unknown reason for the admin user of our Moss site (and all other users who had full control permissions) the Site Action -> Site Settings menu option have disappeared from the home page. I can navigate to it by going to mysite/_layouts/settings.aspx but I can't change anything it says I do not have permissions.

IF the user logged IS the Site Collection administrator and still gets theses access denied messages, your Content Database seems to be locked. This happens during backups or when backups go wrong (get interrupted for example)
stsadm -o getsitelock -url http://server_name

if it is not showing as 'none', it is locked. fix command:
stsadm -o setsitelock -url http://server%5Fname -lock none

I used this command many times but when try to use with some sites it didn't work. I found Power Shell Commands Solved my Problem.
$Admin = new-object Microsoft.SharePoint.Administration.SPSiteAdministration(SiteUrl)
$Admin.ClearMaintenanceMode()
$site.MaintenanceMode



Monday, May 6, 2013

SharePoint 2013 Content source does not crawl

Where created new search service application and tried to crawl, It generate status starting and take a long time without changes and crawl duration still empty like image below.

I tried to recreate service many times and problem still exists.
I found error in Search Application Topology:
I fixed these problems by Fixing Query Processing, Steps to Fix Query Processing:
  1. Run SharePoint PowerShell
  2. Get the Search Service Application and clone the search topology:
    # Clone the active search topology
    $ssa = Get-SPEnterpriseSearchServiceApplication -Identity "Service Application Name"
    $active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active
    $clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active
  3. Get QueryProcessingComponent ComponentId by run command
    Get-SPEnterpriseSearchComponent -SearchTopology $clone
    Get component Id as Figure
  4. Remove the component by using the ComponentId
    Remove-SPEnterpriseSearchComponent -Identity 1c138785-382e-45f3-8e55-ee8d189cf1c0 -SearchTopology $clone -confirm:$false
  5. Add new Search component using command:
    $wfe = Get-SPEnterpriseSearchServiceInstance -Identity "Web front name"
    New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance $wfe
  6. Activate search component
    Set-SPEnterpriseSearchTopology -Identity $clone

After this step error disappear and search topology does not generate error and I succeed crawling.










Monday, April 29, 2013

Cannot delete Column from List

When tried to delete some columns from list using GUI, Some of them don't give me option to delete.
Problem: I Can't delete column if it is sealed, hidden, or readonly
Solution: Change values of these properties to false before trying to delete

You can use PowerShell to change these properties and remove column from List like below:
$web = Get-SPWeb -identity SiteUrl
$list = $web.Lists[listName]
$column = $list.Fields[FieldName]
$column.Sealed = $false
$column.Hidden = $false
$column.ReadOnlyField = $false
$column.Update()
$list.Fields.Delete($column)

Thursday, April 25, 2013

SharePoint Variation Labels error

When tried to access Variation Label on SharePoint I faced error:

Field not found: Label

After investigation, I found article solved my problem:
http://blogs.perficient.com/microsoft/2012/12/variation-labels-broken/

Problem is some one in team changed Display Name of Label Field to Title. variationlabels.aspx page looks reads the item data based on the display name of the field. To solve problem Goto Variation Labels List and Change Title Field to Label and problem will be solved.

Wednesday, April 17, 2013

Design View in SharePoint Designer 2013

Microsoft removed Design View from SharePoint Designer 2013. SharePoint supposed new 2 options for the display of information in custom formats, SharePoint 2013 provides us with two options: 

  1. JSOM (JavaScript Object Model)/JQuery Custom Format
  2. Application of custom display templates to the Content Search web part to display the cross site information.

But we still need to use DataView for these reasons:

  • Problem of first option we need to handle cases of client browsers and crawlers does not support client side.
  • Content Search web part is not up to date.
Although  Microsoft removed Design View from SharePoint Designer 2013 we can create dataview with Share Point Designer 2013. When started to do this i faced many problems like ribbon actions activated or dimmed unexpected, DataView is not exported correctly.

I found article helped me to solve my problem:
http://www.synergyonline.com/Blog/Lists/Posts/Post.aspx?ID=259

I found my problem. I created blank page, I should created it as BlankWebPart. After created page as BlankWebPart and Edit page it in advanced View(with advanced view I cannot edit the page).