Thursday, 2 February 2017

SharePoint Field Types in Elements.xml file

Single Line of Text:

<Field id="{FDDC4E38-25E0-4FD9-92E7-D17F34A5AB12}" description="My Content ID of Item" staticname="ContentID" name="ContentID" displayname="ContentID" type="Text" group="Sample Site Columns" sourceid="http://schemas.microsoft.com/sharepoint/v3">


Number:

<Field ID="{13b3652a-d543-465d-91cb-a9d625637855}" StaticName="Read_Times" Name ="Read_Times" DisplayName ="Read_Times" Description="Read Time count of Item" Type="Number" Group ="Sample Site Columns" SourceID ="http://schemas.microsoft.com/sharepoint/v3">


Date Time:

<Field ID="{d076e4d5-c785-4c04-8b56-c1f021721749}" StaticName="CreateDate" Name="CreateDate" DisplayName="Create_Date" Description="Create Date of Item" Group="Sample Site Columns" Type="DateTime" Format="DateOnly" SourceID="http://schemas.microsoft.com/sharepoint/v3/fields">


Multiple lines of text:

<Field ID="{2ae59f08-0fb0-4a9c-8a31-a180161b1029}" StaticName="PublisherDescription" Name="PublisherDescription" Description="Publisher Description of Item" DisplayName="Publisher_Description" Type="Note" RichText="FALSE" NumLines="6" Group="Sample Site Columns" SourceID="http://schemas.microsoft.com/sharepoint/v3/fields">


Rich Text HTML:

<Field ID="{13cd0291-df15-4278-9894-630913e4d2b9}" StaticName="AccrediterDescription" Name="AccrediterDescription" DisplayName="Accrediter_Description" Description="Accrediter Description of Item" Type="Note" NumLines="6" RichText="TRUE" RichTextMode="FullHtml" Group="Sample Site Columns" SourceID="http://schemas.microsoft.com/sharepoint/v3/fields">


Publishing HTML:

<Field ID="{E2CC0231-FA6C-4F90-839C-118C304DFCF1}" StaticName="PMediaDescription" Name="PMediaDescription" DisplayName="MediaDescription" Type="HTML" RichText="TRUE" RichTextMode="ThemeHtml" Group="Site Columns" SourceID="http://schemas.microsoft.com/sharepoint/v3" UnlimitedLengthInDocumentLibrary ="TRUE">


Publishing Image:

<Field id="{148e8191-afe7-4422-b1d1-7202eda667f1}" description="Image 1 link of Item" staticname="PImageID1" name="PImageID1" displayname="Image_ID1" type="Image" group="My Site Columns" sourceid="http://schemas.microsoft.com/sharepoint/v3" richtext="TRUE" richtextmode="ThemeHtml">


HyperLink & Image:

<Field ID="{635a2031-2088-4413-b54e-d2af5daf08bf}" StaticName="ImageAuthor" Name="ImageAuthor" DisplayName="Image_Author" Description="Author Image" Type="URL" Format="Image" Group="Sample Site Columns" SourceID="http://schemas.microsoft.com/sharepoint/v3/fields">


YES/No Boolean:

<Field ID="{11018312-58f9-4eb0-867d-71298f82d98d}" Name="isActive" StaticName="isActive" DisplayName="isActive" Description="Select if Item is Active" Group="Sample Site Columns" SourceID="http://schemas.microsoft.com/sharepoint/v3" Type="Boolean"&gt;
<default>0</default>
</FIELD>


CHOICES:

<Field ID="{67f8faa4-e3ee-44bf-a3b4-6e7fc9c6b9fe}" Name="Market" StaticName="Market" DisplayName="Market" Description="Market of the Country" Group="Sample Site Columns" SourceID="http://schemas.microsoft.com/sharepoint/v3" Type="Choice"&gt;
<choices>
choice>Gold</choice
</choices>
</FIELD>


MultiSelect:

<Field Type="MultiChoice" DisplayName="Labels_Selected" FillInChoice="FALSE" Group="Sample Site Columns" ID="{2fdf0ba7-0052-4e9f-80f6-e7669ac4ae4f}" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LabelsSelected" Name="LabelsSelected"&gt;
</FIELD>


Lookup Columns:

<Field Type="Lookup" ID="{FE45AC76-C0E2-46C8-A047-E8C43C10315C}" Name="LU_Country" StaticName="LU_Country" DisplayName="LU_Country" Required="FALSE" List="Lists/Region Country Master" ShowField="RollOutCountry" UnlimitedLengthInDocumentLibrary="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3/fields" Group="Sample Site Columns">


Multi Lookup Columns:

<Field Type="LookupMulti" Mult="TRUE" ID="{85062ACF-315B-460A-B756-2230A5FE082F}" Name="LU_Language" StaticName="LU_Language" DisplayName="LU_Language" Required="FALSE" List="Lists/Language Master" ShowField="Title" UnlimitedLengthInDocumentLibrary="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3/fields" Group="Sample Site Columns">


Lookup with Additional Field Lookup column:

<Field Type="Lookup" ID="{9AA2985D-AA17-4EA2-9556-9B0E112A64F6}" Name="LU_ApplicationType" StaticName="LU_ApplicationType" DisplayName="LU_ApplicationType" Required="FALSE" List="Lists/Application Type" ShowField="ApplicationType" UnlimitedLengthInDocumentLibrary="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3/fields" Group="Sample Site Columns">

<Field Type="Lookup" ID="{668D51C4-804D-43E7-8211-950AE3BCD9A3}" Name="LU_ApplicationType_ID" StaticName="LU_ApplicationType_ID" DisplayName="LU_ApplicationType_ID" List="Lists/Application Type" ShowField="ApplicationTypeID" FieldRef="9AA2985D-AA17-4EA2-9556-9B0E112A64F6" ReadOnly="TRUE" UnlimitedLengthInDocumentLibrary="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3/fields" Group="Sample Site Columns">


Note

New GUID can be generated using Tools -> Create GUID (select registy format)

Friday, 10 October 2014

The Feature is not a Farm Level feature and is not found in site defined by - Could not enable Feature

All wsp's have a feature id. We could obtain the feature id of the deployed wsp using the following command.

get-SPFeature

Now search for the feature id of the wsp that you want to enable to a site.
This feature could be activated using the following command.

Enable-SPFeature -Identity FeatureId -URL SiteCollectionURL -Force -PassThru

Note:
FeatureId  Will be the feature id of the wsp 
SiteCollectionURL will be the url of the site in which the wsp has to be enabled.

Sunday, 6 July 2014

Get current logged in user


    To get current logged in user for Sharepoint use this piece of code. You can use this code with custom forms where it gets the current logged in user name.


                        SPWeb getcurweb = SPControl.GetContextWeb(Context);
                        SPUser getcurlogeduser = getcurweb.CurrentUser;
                        string currentusername = getcurlogeduser.Name;



Wednesday, 4 June 2014

Check if current user belongs to particular group


To check if the current user belongs to particular group use the following code.


SPGroup Administrator_Group = SP_Web.Groups["Administrator"];
bool is_Administrator_Group =  SP_Web.IsCurrentUserMemberOfGroup(Administrator_Group.ID);


Tuesday, 11 March 2014

An unhandled exception occurred in the silverlight application sharepoint 2010



              When i try to create a new list or document library in my site, I came across this weird problem.




              The original problem is Silverlight application in sharepoint does not get connected to the Windows Communication Foundation. This dosent allow us to create a list or library in a site. This is just a security issue at server side  and could be resolved by following this procedure.                    


  1. Open Central Administration
  2. Select Application Management
  3. Select Manage Web Applications
  4. Select the Web Application where the error occurs
  5. In the ribbon, select General Settings
  6. In the Web Application General Settings dialog box, find Web Page Security Validation and select On 

This resolves the problem and now a new list or library could be created.                         


Thursday, 6 March 2014

Create site in a new Content Database Sharepoint 2010


      whenever i tried to create a new site in the server it takes up only default content database. I was looking after to create a new site in a separate content database. Unfortunately when i try to create a new site it does not ask me an option to choose the content database that i would like to create the site.

img

I dig up and found that this could be achieved using powershell.

First create a content database using central administration.
To create,

  1)  Central Administration -> Application Management -> Manage Content Databases under Databases.




2) You can see a content database that is already available by default. Here you have to add a new content database. Click Add a Content database.




3) You could rename the database name. Provide appropriate name for your database. Click ok.




4) Now you could see a new content database is created.

  To create a new site in that particular created content database use this following script in posershell.


Powershell Command:

New-SPSite http://yourServerName/sites/YourSite -OwnerAlias "ServerAdministratorUserName" -ContentDatabase ContentDatabaseName -Name "SiteNametobeCreated" -Description "DescriptionabouttheSite" -Template "STS#0"

On successful creation of site over the created database, you will receive this created url.


Thursday, 13 February 2014

Server Dependency error (Missing Feature)


          When we redeploy wsp files in sharepoint server, it will check for its previous version using the feature ID. The old versions feature id will not be available since wsp files has been removed. Though the files have been removed its id will be available in the server.

           It will throw an exception and this exception will be stored in the configuration section. When site content backup is restored this error transfers to the other server too. This exceptions can be removed by using power shell command.

          Go to the following location. Central Administration --> Monitoring --> Review Problems and Solutions under Health Analyzer. Under category configuration click Missing Server side dependencies. There you will find [Missing Feature] type. Now go to Sharepoint Power Shell. and do the following.

PowerShell Remove Features in SharePoint because of Health Issue For "Missing Feature"


Run The below power shell Method in SharePoint Management shell.

 function Remove-SPFeatureFromContentDB($ContentDb, $FeatureId, [switch]$ReportOnly)
{
    $db = Get-SPDatabase | where { $_.Name -eq $ContentDb }
    [bool]$report = $false
    if ($ReportOnly) { $report = $true }
   
    $db.Sites | ForEach-Object {
       
        Remove-SPFeature -obj $_ -objName "site collection" -featId $FeatureId -report $report
               
        $_ | Get-SPWeb -Limit all | ForEach-Object {
           
            Remove-SPFeature -obj $_ -objName "site" -featId $FeatureId -report $report
        }
    }
}
function Remove-SPFeature($obj, $objName, $featId, [bool]$report)
{
    $feature = $obj.Features[$featId]
   
    if ($feature -ne $null) {
        if ($report) {
            write-host "Feature found in" $objName ":" $obj.Url -foregroundcolor Red
        }
        else
        {
            try {
                $obj.Features.Remove($feature.DefinitionId, $true)
                write-host "Feature successfully removed from" $objName ":" $obj.Url -foregroundcolor Red
            }
            catch {
                write-host "There has been an error trying to remove the feature:" $_
            }
        }
    }
    else {
        #write-host "Feature ID specified does not exist in" $objName ":" $obj.Url
    }
}



To run only a report (-ReportOnly property):
Remove-SPFeatureFromContentDB -ContentDB "Content_DBName" -FeatureId "e8389ec7-70fd-4179-a1c4-6fcb4342d7a0" –ReportOnly

To remove the feature from all sites, site collections in the db run (no -ReportOnly property):
Remove-SPFeatureFromContentDB -ContentDB "Content_DBName" -FeatureId "8096285f-1473-45c7-85b7-f745e5b2cf29"  


   This will work only for [Missing Feature] issues.