Monday, November 10, 2014

Multi level of Cascading dropdown in OOB using SPService

Hi,
We are facing problem for cascade dropdown in multiple level using OOB feature. I have one requirement where i need to implement
cascade dropdown in my project. So i have implemented as below.

<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.01/jquery.SPServices.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){
$().SPServices.SPCascadeDropdowns({
relationshipList: "LocationMaster",
relationshipListParentColumn: "Country",
relationshipListChildColumn: "Title",
parentColumn: "Country",
childColumn: "Location",
debug:true
});
$().SPServices.SPCascadeDropdowns({
relationshipList: "StorageMaster",
relationshipListParentColumn: "Location",
relationshipListChildColumn: "Title",
parentColumn: "Location",
childColumn: "Storage",
debug:true
});
})
</script>

Wednesday, November 5, 2014

Add Multiline Text with Enhance Rich option in Clintobject Model

Create Multiline Text

Field styleField = list.Fields.AddFieldAsXml("", true, AddFieldOptions.DefaultValue);
FieldMultiLineText fieldMultiLineText = context.CastTo(styleField);
fieldMultiLineText.RichText = true;
fieldMultiLineText.AllowHyperlink = true;
fieldMultiLineText.UpdateAndPushChanges(true);
list.Update();
context.ExecuteQuery();


Create Multiline Text with ich text option
Field styleField = list.Fields.AddFieldAsXml("", true, AddFieldOptions.DefaultValue);
FieldMultiLineText fieldMultiLineText = context.CastTo(styleField);
fieldMultiLineText.RichText = true;
fieldMultiLineText.AllowHyperlink = true;
fieldMultiLineText.UpdateAndPushChanges(true);
list.Update();
context.ExecuteQuery();


created Enhanced rich text column and use the SchemaXML to generate the new field:

Field rtfField = list.Fields.AddFieldAsXml("" , true, AddFieldOptions.DefaultValue);
rtfField.UpdateAndPushChanges(true);list.Update();
context.ExecuteQuery();


RestrictedMode=\"TRUE\" RichText=\"TRUE\" RichTextMode=\"FullHtml\"

Wednesday, September 3, 2014

Get Site URL in Javascript in sharepoint

Get site and sitecollection url in javascript :
var siteUrl = _spPageContextInfo.webServerRelativeUrl;
var siteCollectionUrl = _spPageContextInfo.siteAbsoluteUrl;

Friday, August 22, 2014

Filter SharePoint task list view to show tasks assigned to groups I am in

If you have a SharePoint task list where the task is assigned to a SharePoint group, you may notice that the My Task list does not show tasks even if you are a member of the group of which the task is assigned.
Before:
<where><eq><fieldref name="AssignedTo"/><value type="Integer"><userid type="Integer"/></value></eq></where>
After:
<where><or><membership type="CurrentUserGroups"><fieldref name="AssignedTo"/></membership><eq><fieldref name="AssignedTo"/><value type="Integer"><userid/></value></eq></or></where>

Ghostable vs Unghostable

Ghosted Page in SharePoint

A ghosted page is a page in SharePoint website which is not stored in the database instead it reference to a file which exists in the server’s file system. These reference files are common for all the website/site collection within that SharePoint server, i.e., if you modify a reference file then that change will reflect in all the websites/site collections within that SharePoint server automatically. So we can say these reference files are used as template.

The default master page of SharePoint “default.master” is a well known example of ghosted page. “default.master” page is located in the directory "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\Global". If you do some changes in the “default.master” then this change will automatically reflect in all the websites within that SharePoint server.
To create a new site in SharePoint, a site template is used. Site template contains description of all the pages, webparts within the pages, master page used, custom lists, etc. for the web site to be created. You can define a page ghostable in the “onet.xml” file of the site template.

Unghosted Page in SharePoint All the pages in a SharePoint website which are stored in the content database are referred as unghosted pages. All the unghosted pages are specific to that SharePoint website only, i.e., changes done in an unghosted pages will not reflect in other websites within that SharePoint server.

If a new website is created with a site template which contains a page defined as “unghostable” in the “onet.xml”, then that page will be stored in the content database of new website created and will not reference to the page available in the site template folder.

If a ghosted page is modified in the SharePoint designer, it will become unghosted. For example if a master page is customized in SharePoint Designer, SharePoint stores a modified version of the master page in the content database and also it breaks the reference to the “default.master” file on the “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\Global“.

Wednesday, June 18, 2014

Cell color change on SSRS based on condition

Hi , I have an requirement like report supposed to be display with different colors based on the -ve and +ve value.
If -ve then "Red"
If +ve then "Green"
Below are the steps :

:)

Tuesday, June 17, 2014

Date comparision on SQL server

Hi , I my report data supposed to display in date filters. While writing query i face problem like it could not fetch data as per my assumption as SQL was also comparing the time value. But for me it should only filter based on the Date part ignoring the time part. So Below is the query to filter date ignoring time from date.
select * from tbl where CAST(FLOOR(CAST(Created AS float))AS datetime) = CAST(FLOOR(CAST(getdate() AS float))AS datetime)
Thank you .

Tuesday, March 11, 2014

Find out current user exists in an AD group or not

Hi, I have a requirement to find out whether the userrent user is belongs to a specific AD group or not. I struggle a lot to find out the solution. Finally I achieved with the below solution.
Step1 : Add the AD group in a sharepoint group
Step 2: Go to the Site Permission ->Groups
Step 3: AD group name will be appear in the "_layouts/15/groups.aspx" page.
Step 4: Note down the AD group name ID
Step 5:Below code required to check the ID
SPContext.Current.Web.IsCurrentUserMemberOfGroup(ID if AD group name noted on step 4)
:)

Use of Array.Foreach() Method

string fileName ="abc#!.txt"; string specialChars = @"\/:*?""<>^|#%&{}~"; Array.ForEach(specialChars.ToCharArray(), specialChar => fileName = fileName.Replace(specialChar, ' '));

Make valid file name for Sharepoint

Hello, We are some times facing problem to validate a file name for sharepoint for special characters. Below is the code for the same :) private string GetValidFileName(string currentFileName) { //this.currentFileNameTemp = currentFileName; string fileName = currentFileName; //special chars not allowed in filename string specialChars = @"\/:*?""<>^|#%&{}~"; //Replace special chars in raw filename with empty spaces to make it valid Array.ForEach(specialChars.ToCharArray(), specialChar => fileName = fileName.Replace(specialChar, ' ')); fileName = fileName.Replace(" ", string.Empty); return fileName; }

Thursday, January 16, 2014

Auto fill Piplepicker control

Some times we are facing problem to autofill user names and groups iin people picker editor in SP 2010. But in SP2013 it provides one control which allow auto fill user names or groupname.
<sharepoint:clientpeoplepicker allowmultipleentities="true" cssclass="ms-long ms-spellcheck-true" id="peoplePicker" principalaccounttype="User,SPGroup,SecGroup,DL" rows="1" runat="server" validationenabled="true" visiblesuggestions="3" > </sharepoint:clientpeoplepicker>
To allow All user and AD groups we need to set the property PrincipalAccountType="User,SPGroup,SecGroup,DL" to as given values .
To access data from the control below is the code set.
SPFieldUserValueCollection mailListUsers = new SPFieldUserValueCollection(); ArrayList resolvedEntities = peoplePicker.ResolvedEntities; foreach (PickerEntity entity in resolvedEntities) { string loginName = entity.Key; SPUser mailUser = compWeb.EnsureUser(loginName); SPFieldUserValue usertoadd = new SPFieldUserValue(compWeb, mailUser.ID, mailUser.LoginName); mailListUsers.Add(usertoadd); }