Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

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:

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>"
}

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)
الالكترونى])))))

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, 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.

Thursday, February 28, 2013

Create a dataview in sharepoint with datasource webservice

To create DataView in SharePoint Desgner based on SOAP Web Service do the following Steps:
  1. From Navigation Pane, click Data Sources.  From Ribbon, click the SOAP Service Connection Menu Item. DataSource Dialog Properties will appear:
    1. Service Description Location: This is the URL to the service description (WSDL) file.
      ex: http://[SharePoint Site URL]/_vti_bin/lists.asmx?wsdl
      Click Connect Now so SharePoint Designer can retrieve the description file. 
    2. Data Command: Like a REST service connection, this box identifies the command  that your data source is going to be configured to run. You need to support multiple datasource if you will use multiple command.
    3. Port: If the web service supports multiple interfaces, they will be listed here. The
      default port will be selected.
    4. Operation: When the Connect Now button is clicked, the wizard retrieves the WSDL
      file, which defines all of the operations that can be performed on the web service.
    5. Parameters: As mentioned previously, if the operation selected in the previous step
      requires parameters, those will be listed.
      If you tried to modify any parameter to set its value you will find check-box you must checked it if you want to your parameter dynamic read from (Control, QueryString, Cookie, Post Data,...)
  2. The wizard has two other tabs that are the same as the other data sources. 
    1. The Login tab can be used to set default login credentials.
    2. The General tab is used to provide a description of the data source configuration. 
  3. Create a new web part page, call it TestSOAP.aspx, and open it in Edit mode. . 
  4. Click in the web part zone, and then from the Ribbon, click Data View and add your data source.
  5. Drag your needed columns from the datasource and apply your adjustment and formatting of data view.
  6. When you finish you can export DataView by the following steps:
    1. click into the Web Part ribbon tab under List View Tools
    2. You have two options, To Site Gallery, and To File. 
Tips and Tricks:
  1. If you set parameter in your web service to read from connected webpart you find ParameterBindings appeared as below (check text in red). You can add more parameters with same way:

  2. <DataSources>
       <SharePoint:SoapDataSource runat="server" id="SoapDataSource1" AuthType="Basic"  
      WsdlPath="http://ServerUrl/_vti_bin/lists.asmx?WSDL"
      SelectUrl="http:// ServerUrl/_vti_bin/lists.asmx"
      SelectAction="http://schemas.microsoft.com/ sharepoint/soap/GetList"
      SelectPort="ListsSoap"
      SelectServiceName="Lists"
      AuthUserName="yellowdc\spadmin"
      AuthPassword="P@ssw0rd"><
      SelectCommand>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
       <GetList xmlns="http://schemas.microsoft.com/sharepoint/soap/">
        <listName>{listName}</listName>
      </GetList>

    </soap:Body></soap:Envelope>
      </SelectCommand>
        <SelectParameters><WebPartPages:DataFormParameter Name="listName"    
              ParameterKey="listName" PropertyName="ParameterValues"        
              DefaultValue="{43AFBEAA-674C-406B-9ACB-0870CD4B88F2}"/>
        </SelectParameters>
      </SharePoint:SoapDataSource>
    </DataSources>


    <parameterbindings>
      <ParameterBinding Name="listName" Location="None"  
                                        DefaultValue="{43AFBEAA-674C-406B-9ACB-0870CD4B88F2}"/>
      <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
      <ParameterBinding Name="ManualRefresh" Location="WPProperty[ManualRefresh]"/>
      <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
      <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
      <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
      <ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/>
    </parameterbindings>

Monday, December 24, 2012

Searching External Systems using SharePoint 2010 Business Connectivity Services (BCS) within throttling limits

SharePoint 2010 Business Connectivity Services (BCS) within throttling limits. To solve this need to split records into chunks.
The LastIdSeen filter enables chunking for IDEnumerator methods. 
For  more information check url:
http://msdn.microsoft.com/en-us/library/ms492695%28v=office.12%29.aspx

Example
http://blogs.msdn.com/b/taj/archive/2010/08/24/searching-external-systems-using-sharepoint-2010-business-connectivity-services-bcs-within-throttling-limits.aspx

Business Connectivity Services (BCS) throttling limits

BCS can only fetch 2000 records at one fetch due to throttling issues. we can resolve this issues in two ways
  1. Switch off the BCS throttling using powershell. This not the best way as it will cause performance issues in future.

    $bdcProxy = Get-SPServiceApplicationProxy | where {$_.GetType().FullName -eq (‘Microsoft.SharePoint.BusinessData.SharedService.’ + ‘BdcServiceApplicationProxy’)}
    $dbRule = Get-SPBusinessDataCatalogThrottleConfig -Scope Database -ThrottleType Items -ServiceApplicationProxy $bdcProxy
    Set-SPBusinessDataCatalogThrottleConfig -Identity $dbRule -Enforced:$false
  2.  Modifying the BCS model to include the Key to Filter Methods.


 

SharePoint BDC Oracle Connection to database using username and password

If you want SharePoint BDC connect to Oracle database using explicit username and password:

  1.  Set up an application definition in Secure Store Service with the Oracle credentials.
  2.  Use AuthenticationMode of RdbCredentials.
  3. When you use RdbCredentials as the authentication mode, you cannot use the RdbConnection User ID and RdbConnection Password properties, as these values are supplied by the Secure Store Service.(Lob connection will be as below)
        <LobSystemInstances>
          <LobSystemInstance Name="OracleInstance">
            <Properties>
            <Property Name="AuthenticationMode" Type="System.String">RdbCredentials</Property>
            <Property Name="DatabaseAccessProvider" Type="System.String">Oracle</Property>
            <Property Name="RdbConnection Data Source" Type="System.String">YOUR_ORACLE_NET_SERVICE_NAME_HERE</Property>
            <Property Name="SsoApplicationId" Type="System.String">SECURESTORE_ORACLE_APP_ID_HERE</Property>
            <!-- Client Ship -->
            <Property Name="SsoProviderImplementation"
              Type="System.String">
              Microsoft.Office.BusinessData.Infrastructure.SecureStore.LocalSecureStoreProvider,
              Microsoft.Office.BusinessData, Version=14.0.0.0, Culture=neutral,
              PublicKeyToken=71e9bce111e9429c</Property>
           </Properties>
          </LobSystemInstance>
        </LobSystemInstances> 
  4. If you specify them, they are simply ignored. You must use Secure Store to supply the Oracle credentials.(Lob connection will be as below)
       <LobSystemInstance Name="PassThrough">
              <Properties>
                <Property Name="ShowInSearchUI" Type="System.String"></Property>
                <Property Name="DatabaseAccessProvider" Type="System.String">Odbc</Property>
                <Property Name="AuthenticationMode" Type="System.String">PassThrough</Property>
                <Property Name="RdbConnection Driver" Type="System.String">{Oracle in OraClient11g_home1}</Property>
                <Property Name="RdbConnection dbq" Type="System.String">XE_ORION</Property>
                <Property Name="RdbConnection uid" Type="System.String">hr</Property>
                <Property Name="RdbConnection pwd" Type="System.String">12345</Property>
                <Property Name="RdbConnection Trusted_Connection" Type="System.String">yes</Property>
              </Properties>
            </LobSystemInstance> 

Saturday, December 22, 2012

SharePoint Fast Search2010 Incremental Crawl BCS


  1. You can add these properties to your list methodInstance in bdc file and deploy again. 

      <
    MethodInstance Type="Finder" ReturnParameterName="DocumentReadList" Default="true" Name="DocumentReadList" DefaultDisplayName="ProductDocument Read List">
             <Properties>
           <Property Name="LastModifiedTimeStampField" Type="System.String">YourModifiedDateField</Property>
      </Properties>
      </MethodInstances>
    For IdEnumerator set __BdcLastModifiedTimestamp Property

     

      <Properties>
        <Property Name="__BdcLastModifiedTimestamp" Type="System.String">LastModifiedOn</Property>
      </Properties>
     

      1. You can add these properties to your list method of entity using PowerShell:
        $entity = Get-SPBusinessDataCatalogMetadataObject  –BdcObjectType “Entity” –Name “EntityName” –Namespace “ModelNameSpace” -ServiceContext adminurl
        $methodinstance = $entity.MethodInstances | where {$_.Name –eq “ReadListName”}
        $methodinstance.Properties.Add("LastModifiedTimeStampField", YourModifiedDateField)
        $methodinstance.Update()
      You can check sample of:
      HOW TO: Create a Searchable SharePoint 2010 BDC .NET Assembly Connector Which Reads From A Flat File

      Metadata Mappings Common Mistake



        When you want manage Metadata Mapping, Somebody use link exists in Queries and Results.
      This link is not correct for SharePoint Fast Search2010, You should Manage Metadata mapping from Fast Search Administration.

      Fast AutoDiscover Properties



      Sometimes will find crawler discover my object crawler properties automatically.  You need to make sure Category Properties defined to allow auto discover. Check Auto Discover property from Fast Search Administration.(You can go to this from any of Fast Service Management)
      Also you can set it from PowerShell:
      Set-FASTSearchMetadataCategory  –Name “Category” –DiscoverNewProperties $flag
      Flag is true/false
      Set-FASTSearchMetadataCategory  –Name “Business Data” –DiscoverNewProperties $true

      Also you can add your crawled properties manual using PowerShell:
      $guid = [guid]::NewGuid()
      New-FASTSearchMetadataCategory -Name MoreWeb -Propset $guid
      New-FASTSearchMetadataCrawledProperty -Name ExtendedTitle -Propset $guid -Varianttype 31