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/

Saturday, May 22, 2010

Using this.Submit to close InfoPath form

Lately I was working on a InfoPath form.  I thought that it will be nice if I can validate the form with custom code and also close it.  I didn't liked the Submit button event handler as it was displaying its own pop dialog box before showing my custom error messages.  I added my own button I tried to use this.Submit() method to execute Submit form option for closing the form, as we know that you cannot call "Close form" from your code.  On form Submit option using "Perform custom action using code" I end up gettting this exception

XmlForm.Submit cannot be called from the SubmitEventHandler.

Finally I figured out that if I use "Perform custom action using rule" on Form Submit options dialog box then from custom button action event handler I can call this.Submit() and it allow for me allowing me to close the form by calling form Submit option - "Close the form".

In case anyone of you interested in how its done here is my project and xsn file -

http://cid-cb9fe32f865358ac.skydrive.live.com/browse.aspx/Public/Submit?lc=1033

also here are some of settings that I had in my form -

On the rule dialog box I just set a temp field to 1,



I hope this will be usefull to those who want to submit and close the form on the same page using code without adding extra view/page to close the form.


Thanks,
Suhaib Khan

Friday, October 23, 2009

Wednesday, October 21, 2009

SharePoint 2010 (Beta) Developer Center

http://msdn.microsoft.com/en-us/sharepoint/ee514561.aspx

What's New in SharePoint Foundation 2010

Atlast for some folks the wait is over here is a list of new features of SharePoint 2010 as posted by Micorosoft -

What's New: Alerts Enhancements

What's New: Business Connectivity Services

What's New: Client Object Model

What's New: Events Improvements

What's New: Microsoft Synch Framework

What's New: Mobile Device Development Enhancements

What's New: Query Enhancements

What's New: Ribbon

What's New: Sandboxed Solutions

What's New: Service Application Framework

What's New: Silverlight Integration and the Fluid Application Model

What's New: UI Improvements

What's New: Windows PowerShell for SharePoint

What's New: Workflow Improvements

SharePoint Products and Technologies (2010)

Finally microsoft started pushing SharePoint 2010 documentation on technet site -

http://msdn.microsoft.com/en-us/library/dd776256.aspx

Wednesday, September 23, 2009

MOSS Limitations pre SP2

Check out performance guidelines and limitations on SharePoint 2007 with SP1 from Microsoft.

http://technet.microsoft.com/en-us/library/cc262787.aspx

Monday, September 21, 2009

Best practices for search performance

In Office SharePoint Server 2007, you also have SharePoint groups. This system is very flexible and can include multiple layers of nesting. However, security principals can adversely affect Office SharePoint Server search performance.


To ensure maximum performance from the Office SharePoint Server 2007 crawler and searches, observe the following rules when you are using Active Directory security principals and SharePoint groups:

Place user accounts into global groups, and global groups into domain local groups. Assign permissions to domain local groups. This is the recommended best practice for using security principals in Active Directory. It ensures that domain controllers can look up group memberships quickly and that users can access resources throughout the forest.
If universal groups are necessary, use the same system but put global groups into universal groups and universal groups into domain local groups.

Put domain local groups into SharePoint groups to assign permissions to SharePoint sites and other resources.


Limit the number of nesting levels used in group membership.

  • Do not Assign Office SharePoint Server site permissions to individual users.
  • Do not Use deeply nested Active Directory security groups.
  • Do not Use distribution lists or security groups that contain contacts.

For more details -
Search Performance

SharePoint Backup Error

If you get the following error message while trying to run the backup process from Central Admin or through stsadm.

"Object WSS_Content failed in event OnBackup. For more information, see the
error log located in the backup directory. SqlException: Cannot open backup
device 'C:\SharePoint\backup\spbr0002\00000012.bak'. Operating system error
3(The system cannot find the path specified.). BACKUP DATABASE is terminating
abnormally. "

To resove this problem, make sure you are UNC path for backup and the account running SQL service has write access to this path, for more detail -
http://support.microsoft.com/kb/207187


Backup plan may fail with the following error
************************** Errors ***********************
Path: http : / / web / sites / wwwwww, Status: Failed.
Error Message: Site Level Backup Backup() error:Write error on file
"sharepoint_bak.dat".
******************************************************

A likely reason that this is failing is that the location where the file is being written to does not have sufficient space.

Friday, September 18, 2009

Remove large SQL 2005 Log file to save disk space

Sometimes we just do not need the big log file, specially if you are working on dev machine with SQL server - true in most cases with SharePoint 2007 server install. So here are the steps to clear some much needed space by removing the database log file. 
  1. Detach the database
  2. Rename the log file
  3. Attach the database without the log file
  4. Delete the log file
Let's say, the database name is WSS_Content. Open your SQL Server Management Studio,
Highlight the database -> Select Tasks , now select Detach and Click OK
Go to your log file folder -> rename the WSS_Content_log.ldf to be like testDev_log-to_be_deleted, and now go back to SQL Server Management Studio follow these steps -

Highlight Databases -> select Attach and click on Add -> add your database WSS_Content, highlight the log file and click the "Remove" button. This attach WSS_Content.mdf and create a new fresh log file.


After this is done, make sure that you verify the contents of the attached database and then delete your old log file.

And please don't forget to run Defrag on your machine, so that you can enjoy better performance.


Have Fun!!

Thursday, August 27, 2009

LDAP filters for MOSS User Profile Import

A typical query for bringing users from AD to MOSS will be -

(&(objectCategory=person)(objectClass=user)

but this will bring all services and disabled accounts, to filter these accounts you can use the following methods -
To remove disabled accounts -
(!userAccountControl:1.2.840.113556.1.4.803:=2) - removes disabled accounts

To remove service accounts (accounts with Password Expiration disabled)
(!userAccountControl=65536)
or
(!userAccountControl:1.2.840.113556.1.4.803:=65536) //in my case this one worked

Here is your LDAP query with these filter -

(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2)(!userAccountControl:1.2.840.113556.1.4.803:=65536))

There might be cases where you want to filter out a particular group, let say you want to exclude users from a group named - FilterGroup, under MYOU, in this case the query will be as follows -

(&(&(objectCategory=person)(objectClass=user)(!userAccountControl:1.2.840.113556.1.4.803:=2)(!memberOf=CN=FilterGroup,OU=MYOU,DC=mydomain,DC=local)))

Some more examples -

Include only the accounts with valid email addresses
(&(objectCategory=Person)(objectClass=User)(mail=*com)

Exclude accounts that don’t have a first name
(&(objectCategory=Person)(objectClass=User)(!(userAccountControl:1.2.840.113556.1.4.803:=2))(!(!givenName=*)))

 Thanks to -
Some more resources -
MSDN – Active Directory Search Filter Syntax

Wednesday, August 19, 2009

List does not exist - SharePoint 2007

While creating a new site based on a site template if you get the following error -

An error occured while rendering navigation for requested URL: /{SITEURL}/currentopps/2009/Test2006. Exception message: List does not exist
The page you selected contains a list that does not exist. It may have been deleted by another user. Stack trace: at Microsoft.SharePoint.Library.SPRequest.GetListsWithCallback(String bstrUrl, Guid foreignWebId, String bstrListInternalName, Int32 dwBaseType, Int32 dwBaseTypeAlt, Int32 dwServerTemplate, UInt32 dwGetListFlags, UInt32 dwListFilterFlags, Boolean bPrefetchMetaData, Boolean bSecurityTrimmed, Boolean bGetSecurityData, ISP2DSafeArrayWriter p2DWriter, Int32& plRecycleBinCount) at Microsoft.SharePoint.SPListCollection.EnsureListsData(Guid webId, String strListName) at Microsoft.SharePoint.SPListCollection.EnsureListsData(String strListName) at Microsoft.SharePoint.SPListCollection.ItemByInternalName(String strInternalName, Boolean bThrowException) at Microsoft.SharePoint.SPListCollection.GetListById(Guid uniqueID, Boolean bThrowException) at Microsoft.SharePoint.SPListCollection.get_Item(Guid uniqueID) at Microsoft.SharePoint.Publishing.PublishingWeb.get_PagesList() at Microsoft.SharePoint.Publishing.CachedArea.GetChildPageIds() at Microsoft.SharePoint.Publishing.Navigation.PortalWebSiteMapNode.PopulateNavigationChildren(NodeTypes includedTypes) at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode.GetNavigationChildren(NodeTypes includedTypes, NodeTypes includedHiddenTypes, OrderingMethod ordering, AutomaticSortingMethod method, Boolean ascending, Int32 lcid) at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode.GetNavigationChildren(NodeTypes includedHiddenTypes) at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider.GetChildNodes(PortalSiteMapNode node, NodeTypes includedHiddenTypes)


This error happens if you are using publishing feature in your site template.