Thursday, January 23, 2014

Small SharePoint 2013 Calendar with day name fix



If you are looking for a small SharePoint 2013 calendar, then Erik has created a nice blog for how to create a small calendar in SharePoint 2013.


As per his instructions I used CEWP with the following CSS –

Note: In SharePoint 2013 you can also use Script Editor web part for adding your CSS as well as JavaScript.

<style>
  .ms-acal-item{height: 10px !important;} .ms-acal-sdiv, .ms-acal-mdiv, .ms-acal-ctrlitem, .ms-acal-month-weeksel, .ms-acal-title, .ms-acal-summary-itemrow TD DIV{height: 15px !important;}
</style>

Now in SharePoint 2013 it will displays calendar with full day names.



I end up using jQuery to reduce the day name length.   Here is the jQuery script that I used to reduced the day name length to 3 character.

<script  type="text/javascript"  src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
<script language="javascript">
$(document).ready(function() {
     $("table.ms-acal-month > tbody > tr > th.ms-acal-month-top").each(function(){
            // get the first 3 chars from day name
        $cell = $(this).text().substring(0,3);
        $(this).text($cell);
   });
});
</script>



 Thanks & Have Fun!!







Saturday, July 28, 2012

Toggle section from within InfoPath form

A simple way to add section toggle from within InfoPath form.
Step for creating form -

Add a new Field - HideShowButtonText, set default value to "t" without quotes

  Steps for adding button -

1. Add new button, Set the button ID to "btnToggle"



2. Set the Label to HideShowButtonText field we created earlier
3. Right Click on the Button and open "Borders and Shading"
4. On Border tab - change Presets to None
5. Click on Shading tab and select No Color then click "OK"
6. Now while your button is selected, change the button text font to "Wingdings 3" and text size to 10


Setting Rules -

1. Double click button
2. Click on Rules...
3. Click Add...
4. Rename Rule 1 to Show Section Rule
5. Click on Set Condition...
6. From field list dropdown pick HideShowButtonText field
7. Select the condition to "is equal to" and set the value part "t" again without quotes
8. Click "OK"
9. Click on "Add Action..." and pick "Set a field's value" from Action dropdown
10. Set the field to HideShowButtonText and Value to "q" without quotes
11. Make sure to check on "Stop processing rules when this rule finishes
12. Add another rule - "Hide Section Rule" as above and this time set HideShowButtonText field to "t" and allow this rule to run when HideShowButtonText = "q"

Section Toggle -

1. Right click any section on your Form which you want to hide or show based on btnToggle button clicks
2. Select "Conditional Formatting..."
3. Set the condition to HideShowButtonText is equal to "t" and make sure to check on "Hide this control"


That’s it we are done with all the required changes now click on Preview and see how you can hide and show section(s) from within InfoPath form.

Feel free to download sample Togglesection.xsn file

Friday, June 22, 2012

Problem with setting field's internal name with AddFieldAsXml


If you are trying to Add fields to a SharePoint list using AddFieldAsXml method with Client Side Object model you might be doing something as below -

using (ClientContext ctx = new ClientContext("http://opc-ad-devspw1/sites/devenf/wb2/%22))
{
       Web web = ctx.Web;
       FieldCollection flds = web.Lists.GetByTitle("MyList").Fields;
       ctx.Load(flds);
                flds.AddFieldAsXml("<Field DisplayName='My Field' Name='MyField' Type='Boolean' />", true, AddFieldOptions.AddFieldToDefaultView);
                ctx.ExecuteQuery();
}

I ran into a problem were my field was getting added, but my internal name was being set to “My_x0020_Field” discarding my Name property.  Finally, after little bit of research I found out that to set field’s internal name with AddFieldAsXml you need to use AddFieldOptions.AddFieldInternalNameHint. 

check here - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spaddfieldoptions.aspx

flds.AddFieldAsXml("<Field DisplayName='My Field' Name='MyField' Type='Boolean' />", true, AddFieldOptions.AddFieldInternalNameHint);

Using AddFieldInternalNameHint fixed my problem and it's not a bug.

Tuesday, October 5, 2010

User Profile filtering options with SharePoint 2010

With SharePoint 2007 applying LDAP filters while importing user profiles from AD was not an easy task, but with SharePoint 2010 Microsoft again done a great job in making it easier for setting up filters for importing user profiles from AD.

Here is an example of importing User Profiles of Enabled user accounts from AD -

To import user profile information of user accounts that are enabled in Active Directory to SharePoint Server 2010, follow these steps: 



  1. On the Manage Profile Service page, click Configure Synchronization Connections.
  2. On the Synchronization Connections page, click the Active Directory connection that you want to edit, and then click Edit Connection Filters.
  3. On the Edit Connection Filters page, follow these steps:


    1. In Exclusion Filter for Users, change the Attribute drop-down to userAccountControl.
    2. In Exclusion Filter for Users, change the Operator drop-down to Bit on equals.
    3. In the Exclusion Filter for Users, select Filter box type to 2.
    4. Click Add.
  4. Click OK.

Note: Similar to userAccountControl attribute you can create a combinations of Exclusion Filter for Users and Exclusion Filter for Groups with a lot of other AD attributes.

A second option which also can be used to filter out user profiles based on OU(s)/user(s)/Group(s) directly from Synchronization Connections.   If you already have a synchronization connection then follow these steps for filtering users based on OU(s)/user(s)/Group(s).

  1. On the Manage Profile Service page, click Configure Synchronization Connections.
  2. On the Synchronization Connections page, click the Active Directory connection that you want to edit, and then click Edit.
  3. On the Edit synchronization connection page, follow these steps:


    1. Click on "Populate Containers" button, (make sure that you entered the password for AD sync account).
    2. Expand the tree view and uncheck any OU from which you don't want user profiles.
    3. You can also expand any OU and uncheck any user/group that you don't want to import.
    4. Click OK.
Issue to be aware of - I was able to select same criteria multiple times and it allowed me to save my synchronization connection without any problem. That was kind of odd.  See below

Attribute Operator      Filter              Action 
accountExpires                                   Is present    
accountExpires                                   Is present    
division                         Equals              A  
division                         Equals              A 

Except this one issue it really works well.


Friday, September 24, 2010

FAST Search - Adding Content Source for Scope Rule type

Note:- Before you follow any blog make sure to check that they are related to the version you are dealing with. Don't follow a blog if its for Beta version of SharePoint 2010 when you have released version.
If you want to create new SCOPES with FAST search, now you can create scope filter from GUI instead of creating them using Windows PowerShell.
From technet -
=========================================
Documented product changes implemented in the August 2010 Cumulative Update (CU) - http://technet.microsoft.com/office/ee748587.aspx. With the CU installed, the FAST Search Server 2010 for SharePoint scope filter is automatically generated based on the scope rules created by using the graphical user interface. Administrators no longer have to create the scope filter manually by using Windows PowerShell.
=========================================
Create and view search scopes (FAST Search Server 2010 for SharePoint)
http://technet.microsoft.com/en-us/library/ff453895.aspx
One thing that is not clear from the above link is, creating scope rules based on content sources with FAST search. It's very easy to do with SharePoint 2007/2010 search - For "Scope Rule Type" you can select "Content Source" and then select your content source from the drop down list.
Now with FAST search on "Scope Rule Type" you won't see "Content Source" as one of the option to select, but it's part of "Property Query" with "Property Query" we can give codition for selecting content source "ContentSource = FileShare"  (assuming that you already created a content source as FileShare).
Long story short with FAST search to access your Content source from a Metadata Property "ContentSource" which can be used to restrict or include results with Scope Rules.

Tuesday, July 6, 2010

SharePoint 2010 Training Resources

Here is a list of SharePoint 2010 resources that I thought might be useful to others -

Get Started Developing on SharePoint 2010

Software developers can use the SharePoint 2010 business collaboration platform to build enterprise-class solutions for intranet portals and the web. Use these ten modules to get started with development for SharePoint 2010 using Visual Studio 2010.


SharePoint 2010 Advanced IT Pro Training

Training to help experienced SharePoint IT Pros improve their skills and gain a deeper understanding of the product.


1|Core Architecture of SharePoint 2010
2|Security in SharePoint 2010
3|IT Pro Management in SharePoint 2010
4|Upgrading to SharePoint 2010
5|Enterprise Search in SharePoint 2010
6|Content Management in SharePoint 2010
7|Composite Solutions in SharePoint 2010
8|Communities in SharePoint 2010
9|Business Intelligence in SharePoint 2010
10|SharePoint Online Overview

SharePoint 2010 Advanced Developer Training

For developers, SharePoint 2010 provides a business collaboration platform to rapidly build solutions and respond to business needs. SharePoint 2010 Advanced Developer Training offers technical training as self-paced modules and hosted labs for SharePoint 2007 professionals who want to upgrade their skills to SharePoint 2010.

1|Developer Roadmap and Tools
2|Core Development
3|User Interfaces and Lists
4|Data Access in Technologies
5|Composite Solutions
6|Enterprise Content Management
7|Enterprise Search
8|Business Intelligence
9|Communities
10|Development Life Cycle

Wednesday, June 16, 2010

Convert UTC date using Convert.ToDateTime Surprise

While working on a project I had to convert a date string to DateTime object. As the date value was coming from SharePoint it was a UTC date - "2010-01-01T00:00:00Z". So looking at the date value I expected that Convert.ToDateTime or DateTime.Parse will return me 1/1/2011 12:00:00 but to my surprise I was getting 12/31/2010 7:00:00 PM I quickly realized the mistake I was doing and searched MSDN and thanks to SPUtility class for the rescue. So convert UTC date string to a DateTime object use the following method to get the correct date -

objectDateString is object type with value "2010-01-01T00:00:00Z"

SPUtility.CreateSystemDateTimeFromXmlDataDateTimeFormat(objectDateString.ToString()) returns {1/1/2011 12:00:00 AM} System.DateTime

or the following will also return correct date -

Convert(objectDateString.ToString()).ToDateTime().ToUniversalTime()



using DateTime.Parse or Convert.ToDateTime I was getting wrong dates -
DateTime.Parse(objectDateString.ToString()) returns {12/31/2010 7:00:00 PM} System.DateTime

Convert.ToDateTime("2010-01-01T00:00:00Z") return  {12/31/2010 7:00:00 PM}

Again lesson learned to treat DateTime values with respect. :)

For more information in this -
http://www.jamestsai.net/Blog/post/SPRegionalSettingsGlobalTimeZones-How-to-build-world-clock-get-time-zones-information-in-SharePoint.aspx

http://www.novolocus.com/2008/07/31/sharepoint-web-services-and-utc-time-fun-and-games/