Archive for the ‘SharePoint’ Category

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/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.

06/22/11
Fahad Zia
tags:  

Downloadable content for SharePoint 2007/2010


http://technet.microsoft.com/en-us/library/cc262788.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/
12/13/10
Fahad Zia
tags:  

Renaming SharePoint Title site column back to Title throws error: “The Column name you entered is already in use or reserved.Choose another name”


reserved_column_name

It is recommended not to rename OOTB Title site column but if for some reason you have done this. There are 2 ways it can be changed back:

1. Using SharePoint Manager
http://spm.codeplex.com
This is easier of the two and it requires you to install SPM 2007 on the SharePoint server you are making changes to. Open SPM and drill down to the site collection’s fields collection and click on changed Title field (InternalName=’Title’). In the “SchemaXml” value change “DisplayName” back to “Title” and save the changes.

2. Using SharePoint Object Model
Use the following articles to run the code on the server.
http://support.microsoft.com/kb/923589
http://sharepoint.microsoft.com/Blogs/fromthefield/Lists/Posts/Post.aspx?ID=15
http://www.endusersharepoint.com/2009/01/21/hidden-content-types-and-hidden-site-columns/
Note the use of “PushChangesToLists” method in the first article that will modify this field in the list too which cant be done from SPM.

If you wonder why this happens, check this post:
http://hristopavlov.wordpress.com/2009/01/15/the-column-name-that-you-entered-is-already-in-use-or-reserved-choose-another-name/

12/10/10
Fahad Zia

Workflow History List URL for SPD/WF/Nintex


If you are logging messages as part of your workflow and need to see where it goes then go to your site where workflow is running to view this hidden list:
SPD/WF: http://SiteURL/Lists/Worflow History

If you are using Nintex Workflow 2007, then the logs can be seen here:
Nintex: http://SiteURL/Lists/NintexWorkflowHistory

09/30/10
Fahad Zia
tags:  

Lists.asmx GetListItems dataset does not include empty column


To better explain this, lets say i have a list with the following columns:

Department, Position
IT, Senior System Administrator
IT, Junior Programmer
HR,

using GetListItems on this list will include ows_Position node (provided that the CAML query does not have any filters for this example so its a SELECT * ) but now if the same list and query has no data in Position column:

Department, Position
IT,
IT,
HR,

the GetListItems will NOT have ows_Position node.
I recently came across this issue when reading values from a list that had an empty column and after converting the GetListItems to a dataset the datatable would not have this empty column listed

09/28/10
Fahad Zia

ProcessBatchData: Value does not fall within the expected range


This may apply to other funtions that use xml file but in my case i was using ProcessBatchData with correctly formatted xml string as the argument (atleast thats what thought since I could open the xml string fine in IE and Visual Studio debugger). After hours of debugging and googling i found out that it was because i was using single quotes in xml declaration!:
Wrong :

string strXML = "<?xml version='1.0' encoding='UTF-8'?>"

Correct:

string strXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" 

Page where i found this:
http://pholpar.wordpress.com/2010/02/05/how-to-change-the-order-of-the-fields-on-a-sharepoint-form-using-code/