09/25/13
Fahad Zia
tags:  

Create nullable columns using SELECT INTO


SELECT
CAST('' AS nvarchar(10)) AS Col1
,CAST('' AS nvarchar(100)) AS Col2
,CAST('' AS int) AS Col3
,CAST('' AS bit) AS Col4
INTO Test
WHERE 1=2

nullable_columns_table

02/08/13
Fahad Zia
tags:  

SharePoint List Validation


Scenario: When the “Is Rebill” column(Yes/No) is Yes then “Rebill Amount” column cannot be empty. So this is the formula I wrote:

=IF([Is Rebill]="Yes",IF([Rebill Amount]="",FALSE,TRUE),TRUE) 

It did not work. The issue above is with Is Rebill=”Yes” which should be Is Rebill=True

Correct formula:

=IF([Is Rebill]=True,IF([Rebill Amount]="",FALSE,TRUE),TRUE) 
03/05/12
Fahad Zia
tags:  

Provisioning Files to a Features’s root folder in SharePoint 2010


http://henry-chong.com/2010/12/provisioning-files-to-a-features-root-folder-in-sharepoint-2010/

11/03/11
Fahad Zia
tags:  

List Stored Procedures by Modified Date


SQL Server 2005:

SELECT * FROM sys.objects WHERE type = 'P' ORDER BY modify_date  DESC

SQL Server 2000:

SELECT * FROM sysobjects WHERE type='P' ORDER BY crdate DESC; -- refdate supposedly should be the date modified column but both return the same date

If you notice in SQL 2000, crdate and refdate show the same date so there is no way to sort by date modified with the above query

11/01/11
Fahad Zia
tags:  

InfoPath Forms Services Hidden Field Validation


I was unable to to suppress validation on a hidden field so here is what came up with, which doesn’t look like the best approach but works.
Shown below is the form in which “Employee” text field is mandatory and “Officer” dropdown is only required if “Get Approval” checkbox is true.

The “Section” under “Get Approval” checkbox is an “Optional Section” control with “Default settings” set to “Include the section in the form by default”. And under “Display” tab the “Conditional Formatting” is set as follows:

Note that I did not set “Cannot be blank” for the officer dropdown since this will not let the form submit even if it’s not visible. Instead I created the rules and conditions on the “Submit” button as shown below:

The validation that is set reads:
Submit the form when any of the following is true:

  1. Approval is required and Officer field is not blank
  2. Approval is not required and Employee field is not blank

The screenshots below show the settings.

10/30/11
Fahad Zia
tags:  

Postback with ASP.NET button inside Facebox


http://weblogs.asp.net/kariemsoudy/archive/2009/11/02/buttons-inside-facebox-popup-don-t-postback-fix.aspx

06/22/11
Fahad Zia
tags:  

Downloadable content for SharePoint 2007/2010


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

06/02/11
Fahad Zia

Disabling Calendar Days in Telerik RadDatePicker


Its not easy as setting a property. Check the solution here:
http://www.telerik.com/community/code-library/aspnet-ajax/calendar/disabling-calendar-days.aspx

05/06/11
Fahad Zia
tags:  

SharePoint list ID column in a calculated column does not update


To show what I am talking about, create a custom list and add a calculated column called “Print ID” with the formula “=ID”. Add a new record with Title as Test and you will see something similar to below:

id1

The “Print ID” column displays 0 although if you hover over the title “Test” you see ID=1. This happens because when the item is added it did not have the ID generated in the database yet. So to update this column, go to the “Print ID” calculated column of the list, edit it and press OK which recalculates the formula and shows the correct value of ID as shown below.

id2

Unfortunately it does not end there as if you edit this item the “Print ID” column again resets to 0 which means you will have to ONCE AGAIN update the calculated column. With the knowledge that the calculated column needs to be updated after the item is added and after the item is modified, we can create an event handler that automates this for us. Here is the solution I used:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace NCR
{
    class NCRListEventHandler: SPItemEventReceiver
    {
        /// <summary>
        /// Update NCRPrint calculated column so ID column is not blank. Without this new items have ID empty in NCRPrint column
        /// </summary>
        /// <param name="properties"></param>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            UpdateNCRPrintField(properties);
        }

        /// <summary>
        /// Without this the ID in the calculated column after update becomes 0 or empty
        /// </summary>
        /// <param name="properties"></param>
        public override void ItemUpdated(SPItemEventProperties properties)
        {
            UpdateNCRPrintField(properties);            
        }

        private void UpdateNCRPrintField(SPItemEventProperties properties)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(properties.SiteId))
                {
                    using (SPWeb web = site.OpenWeb(properties.RelativeWebUrl))
                    {
                        SPField fldNCRPrint = web.Lists.GetList(properties.ListId, false).Fields.GetFieldByInternalName(Helper.FieldNames.NCRPrint.ToString());
                        fldNCRPrint.Update(true);
                    }
                }
            });   
        }
    }
}
03/25/11
Fahad Zia
tags:  

SharePoint 2010 Themable Locations


In SharePoint 2010, comments in alternate CSS file can be used to change the default CSS style. These comments are applied when the CSS files are located in “Themable” locations. These locations are:

  1. 14\TEMPLATE\LAYOUTS\1033\STYLES\Themable
  2. Site Collection:
    • /Style Library/Themable/ : This folder needs to be manually created in SP2010 Foundation and SP2010 Server
    • /Style Library/[language]/Themable/