Tuesday, November 4, 2008

Calendar: New Event - Hide 'Workspace' from NewForm or EditForm page

Somebody asked me about hiding a field called 'Workspace' from Calendar: New Event or Edit existing event.
I was wondering that there should be some decent way to hide any field available on 'New' or 'Edit' page.
I googled around, and I found couple of responses, forexample,
1. Modifying the NewForm.aspx page in SharePoint Designer 2007, hiding existing List Form Web Part, and then adding Custom List Form. Then delete the Workspace row from the form.

Let me talk about the dis-advantages of this option:
a. Attach File will NOT work. You need to investigate further to make it work. Still painful process.
b. Try to create a 'Recurring' event, it will not work as expected.

Considering these advantages, I thought that this is very tedious process, and one has to make the changes to all calendar lists. And then this change is required to be done on NewForm.aspx and EditForm.aspx. How about that? So it is really very painful process.

2. Another option is again, modifying the NewForm.aspx or EditForm.aspx, and add following script (However, it didnt work for me though), but it is worth adding it here, just in case, if people are trying to solve the problemin this manner.
<script language='javascript' type='text/javascript' >
var toolbar = document.getElementByName("<name attribute value>"); toolbar.parentNode.parentNode.parentNode.style.display = 'none'; toolbar.parentNode.parentNode.style.display = 'none';
<script>

This can be added in asp:content ContentPlaceHolderId="PlaceHolderTitleAreaClass".
Once again as I said that it didnt work for me, but it can be done this way too.

3. Recommended way. First thing is that it is a feature, and can be found (12 Hive folder) at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Template\Features\EventsList. Yes, it is event list feature. Now the modifications are required in schema.xml that can be found under Events folder (folder location, once again, is ..\12\TEMPLATE\FEATURES\EventsList\Events). This file can be modified in notepad.exe.
While looking into the Calendar List Settings in Internet Explorer, I noticed that this field 'Workspace' is of type 'Cross Project Link'. This is important to remember, and search 'CrossProjectLink' in schema.xml file. I noticed there is only one instance of it.
Secondly, the field is SharePoint field so looked for the corresponding class which is SPField. I looked into SPField Class Members on
MSDN and found a couple of interesting properties (and used two of them), for example, ShowInDisplayForm, ShowInEditForm, ShowInListSettings, ShowInNewForm, ShowInVersionHistory, ShowInViewForms. I was interested in ShowInEditForm and ShowInNewForm properties only. So in schema.xml file, for Field of Type="CrossProjectLink", added these two properties as attributes, and set the value="FALSE".
IMPORTANT: attribute value should be set as ShowInNewForm="FALSE" (case sensitive). If you set the value as ShowInNewForm="false", it will not work, so be careful here.
My final <Field> is looked like:
<Field ID="{08fc65f9-48eb-4e99-bd61-5946c439e691}" Type="CrossProjectLink" Name="WorkspaceLink" Format="EventList" DisplayName="$Resources:core,Workspace;" DisplayImage="mtgicon.gif" HeaderImage="mtgicnhd.gif" ClassInfo="Icon" Title="$Resources:core,Meeting_Workspace;" Filterable="TRUE" Sealed="TRUE" SourceID="
http://schemas.microsoft.com/sharepoint/v3" StaticName="WorkspaceLink" ShowInEditForm="FALSE" ShowInNewForm="FALSE">
As mentioned, I added only two attributes.
Save the schema.xml file.

Now the task is to publish the feature with changes. And since the feature is already installed and activated, so it is mandatory to de-activate it and then un-install it.

To smoothen the process I wrote two batch files one each for de-activate, un-install and install, activate:
script for uninstallfeature.bat

path="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"
cd\
cd "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"
stsadm.exe -o deactivatefeature -filename EventsList\Feature.xml -url
http://moss2007:8551/sites/Demo1
stsadm.exe -o uninstallfeature -filename EventsList\Feature.xml -force
cd\

It is straight forward to understand, however, if you want instructions for the same, can send me request.

script for installfeature.bat

path="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"
cd\
cd "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"
stsadm.exe -o installfeature -filename EventsList\Feature.xml
stsadm.exe -o activatefeature -filename EventsList\Feature.xml -url
http://moss2007:8551/sites/demo1
cd\

URL is required to install the feature, in this script, I am deploying the feature for a specific website.
Dont forget to do IISRESET

I am done, and when I tried to create or edit a calendar event, I don't see 'Workspace' option in there. I double checked that attach file is working, and I am able to create a 'Recurring' event too.
It is really very useful tip for me, so thought let me add it here for future reference too.


Update as on 01/13/2009:
1. The approach described here is applicable for a website. For example, if there are different calendars for different locations or divisions for an organization, then this approach can be used to hide a field in all calendars in that website. However, if the requirement is to show/hide 'Workspace' field for a specific list, there is a tool available in http://www.codeplex.com/spm [Thanks for Boris].

Monday, October 13, 2008

SQL Express 2005 - changing sa password from osql command

I installed MOSS 2007 on stand alone system, and by default it installed with SQL Express 2005. Now I wanted to connect to it from osql command using 'sa' account, I tried to connect to it using sa and 'null' password but failed with error 'Login failed for user 'sa''.
I googled and found very interesting support article here.

The steps to change the 'sa' password from command prompt is given here.
1. Goto Command Prompt.
2. Type: osql -E -S servername\instancename [and press Enter]. This option will work only if you are logged on as administrator on the machine or using the account that you used while installing sharepoint. Otherwise this option will not work. It worked for me because I am the administrator on my machine and same account was used to install MOSS.
3. After successfully connected to SQL instance you will see sql prompt as ">".
4. Type:
1>sp_password @old=null, @new='pass123#$', @loginame='sa'
2>go
1>
Important: @loginame (this is correct, there is no double "n" in login name... )
You must see 1> once password is changed successfully. Quit from windows authentication, and try connecting using the new 'sa' password.
1>quit
C:\>
C:\>osql -S servername\OfficeServers -U sa -P pass123#$ [and Press Enter]. You should be able to see the SQL Prompt which is:
1>

Hoping it is useful for someone as it was for me.

Monday, July 14, 2008

Who is connected to a server using Remote Desktop (command line command)

I was trying to connect to a machine, and then I get 'terminal server connection exceeded...' notification.
I was wondering if there is a way to find out who is connected to the machine so that i can send an email who is in 'Disconnected' mode or something.
I took the help of a network administrator, and he gave me one simple command that I ran from command line and it gave me the list of all sessions connected/disconnected to the machine.
Here you go:
C:\>qwinsta /server:urservername [press enter]

If you want to remove any instance/session, then run the following:
C:\>rwinsta /server:urservername ID# [press enter]

I like to mention it here though.

Read AppSettings Section from MyApp.dll.config

Its been long time, when I was struggling to read DLL Configuration file settings, and finally I found the solution. My app.config content is as :


<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler"/>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" ><section name="Lab3.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
<param name="File" value="C:\\AppConfig\\Log.txt"/>
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Composite"/>
<param name="DatePattern" value="yyyyMMdd"/>
<param name="MaxSizeRollBackups" value="10"/>
<param name="MaximumFileSize" value="50KB"/>
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d %-5p %c [%x] - %m%n"/>
</layout>
</appender>
<root>
<priority value="ALL"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
</log4net>
<appSettings>
<add key="UserName" value="MyUserName"/>
</appSettings>
<applicationSettings>
<MyApp.Properties.Settings>
<setting name="MyApp_SampleWS_Service1" serializeAs="String">
<value>http://localhost/SampleWebService/Service1.asmx</value>
</setting>
</Lab3.Properties.Settings>
</applicationSettings>
</configuration>


The assembly (MyApp.dll) is deployed in GAC, and the once compiled, I copied MyApp.dll.config from build folder to C:\AppConfig. This path is hardcoded in the code so that it can be picked up easily by the code.
This app.config has three major parts:
1. Log4Net - to write log details in a text file.
2. AppSettings
3. WebService Reference.

The piece of code that reads this config file from C:\AppConfig location:


ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = @"C:\AppConfig" + @"\MyApp.dll.config";
if (!File.Exists(fileMap.ExeConfigFilename))
{
logger.Info("File " + fileMap.ExeConfigFilename + " does not found.");
return;
}
assemblyConfig = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
AppSettingsSection appSettings = assemblyConfig.AppSettings;
logger.Info("App Settings found");
logger.Info("Key=UserName, Value=" + appSettings.Settings["UserName"].Value);
logger.Info("End of Information");

And two static variable declarations:

private static ILog logger = LogManager.GetLogger("Atul.Sample.ConfigSample");
private static Configuration assemblyConfig;

Add following line of code in AssemblyInfo.cs too to make log4net working correctly.

[assembly: log4net.Config.XmlConfigurator(ConfigFile = @"C:\AppConfig\MyApp.dll.config", Watch = true)]

Once again, make sure to copy 'MyApp.dll.config' in the C:\AppConfig location to make it work correctly.

Assumption is that your assembly is 'strongly named' as this is required for deployment in GAC.

Thursday, July 10, 2008

Installing MOSS 2007 on Windows Vista home edition (32Bit)

First of all, thanks to the authors of the website who published ways to install Windows Sharepoint Services 3.0 on Windows Vista Operating System.
The URL is
Hats off to the URL content authors!!!

I applied the steps mentioned in the URL. I have windows vista home premium 32bit operating system. However, URL doesn't claim that they have tested installation on Home Premium, however, I did. And I have installed it successfully.
I have SQL 2005 Developer Edition as well as SQL Express. Also have Visual Studio 2008 with .NET framework 2.0, 3.0 and 3.5.
Why I looked these options, because initially I wanted to run virtual PC 2005 or 2007 so that I can run virtual Hard Disk for MOSS 2007. As per the installation instructions, it doesn't support installation on Vista Home, and thanks to google that helped me to find bamboo solutions.
So, I downloaded the files per the URL instructions, and run the installation. While configuring the Sharepoint Services Database, I used SQL Server 2005 default named instance but configuration failed with some errors. Actually I deviated the installation per given the instructions in the URL. Once it failed, I followed the same instructions (installing it on SQL Express instead of regular SQL Default instance), and installation completed smoothly.
Now the challenge starts. I successfully start the Sharepoint services http://servername:8260/
First task is to create a web application, and created it successfully however, when I started the URL it failed with two different errors:
1. Internet Server Error - error on the web.config file.
2. Access Denied.
Please note that I opted Anonymous and Windows Authentication. However, Vista Home doesnt support Windows Authentication, it does support Basic Authentication. So once again I looked into the same URL for possible reasons how to make the website work, but in vain. People were talking about UAC (User Access Control) settings, though I did change it but in vain. So I reverted back all changes.

I tried all options:
1. Changing UAC Settings.
2. Changed Authentication mode in IIS 7.0. 'Basic Authentication' is enabled.











Even completed these steps didnt help me much, so was thinking that what exactly am I missing. And finally I get a breakthrough in the central administration itself.




















Click Save to save settings on Authentication Provider page.

Once I changed the option, it solved the problem and I was able to run my team site successfully.



Friday, June 13, 2008

Installing Windows Vista Ultimate 64-bit on DELL XPS M1330

Well, I am not doing something new here. I bought DELL XPS M1330 last year. It came with following configuration:
Intel Core 2 Duo T7500 (2.2GHz)
3GB RAM, 160GB HDD (7200rpm)
nVidia 8400M GS 128MB Graphics Card,
Intel 4965 Wireless card
9Cell battery
Pre-Installed Windows Vista Home Premium 32-bit.

Well, I did buy Windows Vista Ultimate (32 and 64-bit), so upgraded the machine without any problems though, to Vista Ultimate 32bit. It worked pretty well, and smoothly. Surprisingly Windows Vista does search all the updated drivers automatically, if the machine is connected to internet and install the most appropriate one automatically.

So long story short, I always wanted to have or to feel 64-bit taste. And one crazy day, I made a decision and started the installation. As soon as I completed the first stage of 64-bit installation of Vista Ultimate, I didn't get any success as I was getting BSOD (blue screen). I was unable to look into the error too because machine restarts within seconds as soon as it displays the error. So I spoke to DELL technical support and spent more than 24 hours (in three days) and issue was ATA/AHCI settings in BIOS. Frankly speaking, I really dont know what is the difference, but expert suggest that it should be AHCI.
I followed the instructions given in the following post, and believe me, it is very good and informative, though you will get lot of new information too, here you go:
http://forum.notebookreview.com/showthread.php?t=158277

Also, I refer following websites while investigating on the issues:
http://support.intel.com/support/chipsets/imsm/sb/cs-020644.htm - This website will explain about the chipset installed on your machine and also gives you insight what needs to installed, version etc.

I followed the steps given in the following post:
http://forum.notebookreview.com/showthread.php?t=164159. Before that I installed Vista Ultimate 64-bit in ATA mode (Flash Cache Mode was OFF). And then followed the instructions given in this post. Did the change in the BIOS (as given) and it worked without any problems. And then I followed the instructions as per the first post (http://forum.notebookreview.com/showthread.php?t=158277).

I was very frustrated earlier while talking to Dell technical support, but patiently executing all the troubleshooting steps as they were telling.

Now this laptop is working fine, and windows update is going on right now, while writing down this post using another computer :).

Now the next step is to upgrade the RAM from 3 GB to 4 GB to fully utilize the 64-bit environment.

Monday, January 28, 2008

HTTP Error 500.19 - Internal Server Error

This is the problem I faced when I copied IIS 6.0 web application on to IIS 7.0. The steps that I executed are:
1. Copied the web application on to a different folder, C:\Users\Name\....\myWebSite.
2. In IIS 7.0, created a new 'Application' (please note that I haven't created virtual directory).
3. The physical folder location is same as defined in step 1 above.

I thought that I am done with my configuration, but when I tried to open 'Default.aspx' in the browser, I get this error.
Description: The requested page cannot be accessed because the related configuration data for the page is invalid.
Error Code: 0x80070005
Notification: BeginRequest
Module: IIS Web Core
Requested URL: http://localhost/MyWeb/Default.aspx
Physical Path: C:\Users\LoggedOnUser\...\Default.aspx
Logon User: Not yet determined
Logon Method: Not yet determined
Handler: Not yet determined
Config Error: Cannot read configuration file
Config File: file:///?\C:\Users\loggedOnUser\...\web.config
Config Source:
-1:
0:

More Information... This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
--------------------------------------------------------------------------------
Server Version Information: Internet Information Services 7.0.

Seeing this error, it striked in my mind that definitely it is related to configuration settings in IIS 7.0. I checked the following settings:
1. Authentication - It was disabled for 'Windows Authentication'. I enabled it for the web application.
2. But then also, when I tried to open the default page, i get the same error.
I was thinking that why it is not working, then thought to do some hit and trial versions. The very first step I did is to create a new application pool and instead of using 'NetworkService' as Identity, I set the identity to machineName\userName, in my case because I am not the domain user, so I used machineName\LocalAdministrator. And finally, I set the application pool of the web application to this new application pool.

Bingo! It worked!
I need to explore more of IIS 7.0 features, and actual differences / advantages.

Thursday, January 10, 2008

Required file alink.dll with IAlink3 could not be found

I copied the VS.NET 2005 application from a machine running Windows XP Professional on to another machine with configuration [Dell XPS Intel core 2 Duo, 2.2 GHz processor with 3GB RAM and 160GB HDD (7200rpm)] and Windows Vista Ultimate operating system. Well when I copied the files on to the local XPS machine the challenge was to execute the console application. The very first error I was facing (a) Required file alink.dll with IAlink3 could not be found.

Problem: Required file alink.dll with IAlink3 could not be found.
Solution: I thought that definitely it is something related to either operating system or orcus (VS.NET Studio 2008). As usual the very first thing a developer does is to look for a probable solution in google, and thats what I did too. The very first link was talked pretty well about the solution.

The URL is:

http://codebetter.com/blogs/sam.gentile/archive/2007/04/29/workaround-for-orcas-beta-1-compile-problem-required-file-alink-dll-with-ialink3-could-not-be-found.aspx.

In this if this URL is out of service or content is not available, the details are given here too (courtsey to the URL author).
URL Content

------------------------------------------------------------------------------------
Required file 'alink.dll with IAlink3' could not be found.
I am very grateful to two very fine Microsoft gentlemen that heeded my cry and came to my aid. The first was Tim Ng, who pointed me to the existing forum thread where the problem and a first workaround was posted by Pat Long:
The MSUs are located on the Install CD under \WCU\dotNetFramework\dotNetMSP\x86 and they are called
Windows6.0-KB110806-x86.msuWindows6.0-KB929300-x86.msuWindows6.0-kb930264-x86.msuThey needed to be run manually in order. The problem was when I tried to run the 3rd update it would always fail. At that point, Tim brought in another Softie, Jared Parsons, who came up with the solution and the workaround. We're still working on the issue but if you encounter this problem, the following will get you working!

Another update. This error message occurs because the C# compiler is trying to embed a Vista manifest into your DLL. I believe you can also work around this problem by doing the following.
Navigate to the properties page for the project. At the bottom of the Application tab (should be selected) there is an label called "Manifest" and a combo box underneath that says "Embed manifest with default settings". Switch that to "Create Application without a manifest". I know that will work around the warning in VB and I'm pretty sure it will with C# as well.
Thanks Guys!!!!
-----------------------------------------------
I read this post and then recalled that Gosh! I dont have the operating system DVD handy. A sudden thought "Am I stuck?". Can't I proceed without it. Then I read further in the given solution where it talks about the "vista manifest". I just changed the manifest option from "Embed manifest with default settings" to "Create application without a manifest", and compiled my application (which was an exe). Bingo! Application ran without any problem.

Now my next action item is to investigate on this "Manifest" option, what is the difference and what are the advantages and disadvantages.