Thursday, July 31, 2008

SharePoint Configuration Wizard Fail


Just installed a KB from microsoft on my SharePoint server and when I tried to run the configuration wizard afterwards I got a strange error message:
Could not start service SPSearch

Naturally, I went to have a look in "services" and I found that the "windows sharepoint services search" service was stopped, and could not start...

Starting it says it cannot login due to wrong username / password... strange...
I updated the correct password - started it - OK,

So - back to the wizard... running the wizard - same error message - checking the service - login failed...

After 4 or 5 times my stuck trace overflowed I guess, so I started thinking... why would the wizard change my service user name / passwor?

Than it came to me: I updated the SP admin user password a while back, and thought I updated it every where. Even used some stsadm -o upgradefarmcredentials and other credential updates...

But - than I came accross this command:
stsadm -o spsearch -farmserviceaccount domain\spadminuseraccount -farmservicepassword xxxxx

After runnign this command the wizard completed successfully.

I must say that the only reason I knew it had anything to do with the SPSearch is by watching every step of the wizard. The after-crash log file they propose is useless!!!

Well, when failing the wizard - here is another thing to keep in mind!

How to add Source parameter to SharePoint links automatically?


You know when you click a link to view item in SharePoint list and when you click Close it goes back to the page you came from?
Or when you edit an item - clicking OK returns you the page you original came from?

Well, you may have noticed SharePoint does that by adding the "Source=" url query string parameter to the address, and uses it to knwo where to go after we user is done.

So, basically - you can use that to redirect the user anywhere you want after he finishes with the form you sent him to, but - what if you want it to automatically be set to the current page's address?
Of course you can hard code the page's address, but what about additional query string parameters, of multiple addresses to the same page (different host headers)?

There is an easier way - the way SharePoint adds the "Source" parameter -
simply add this bit to your a link in HTML:
ONCLICK="GoToLink(this);return false;"

so that your link will look like:
<a href="/Docs/Lists/Announcements/DispForm.aspx?ID=1" ONCLICK="GoToLink(this);return false;">view item</a>

The GoToLink will automatically add thye current page's address before navigating to the HREF you entered!

Shai Petel

Monday, July 28, 2008

VM Server cannot connect to network after restore from save state

Ok, I know I am a bit off topic here, but we all use VMs, Right?

So let me start by congratulating MS for their Win2k8 64bit Hyper-V server (Amazing!), but for most of us we still use the Virtual Server on Win2k3, right?

Well, after installing the SP1 for the virtual server R2 i started having this problem:

I Saved state of my machine
Restarted the server (host)
Resumed the virtual machine and boom - the virtual server service halt and crashed, and after manually starting it i got an error starting virtual network connection and no more network for that machine...

Here is the error message:
The virtual machine cannot connect virtual network adapter 1 because another virtual machine with the MAC address is already running. This virtual network adapter will be left disconnected.

Only solution I found (worked some times) was to restart the server, start another machine first (dummy one i dont use) stopping it and than i had a 60% chance that the problem was solved for that session.

Now, for my network I have to use Static MAC address for network cards so i cannot change the MAC address on the VMs.

Today I found a new solution for that issue:
I went to the network card where the virtual network is connected, clicked properties, and unchecked the "virtual machine network services".

I clicked OK, waited for things to proccess my change, and than went back in and checked it again.

And what do you know? Things started to work again - no restart... no removing the virtual machine...

Well, hope it helps you guys, I seen a lot of posts on this but none reported a solution like that.


Monday, July 21, 2008

How to hide a field in edit or new item form

I get this question a lot...

How can we hide a field from a specific user, or completely from the edit or new form?

Well the hard way (and SharePoint approved) would be to write some .NET code against the SharePoint API and changing the field visibility - I will not go into it now.

Other way - still hard, is to change the field CAML definitions (Xml files) - also for existing fields not recommended at all - I will not go into it now as well.

There is a much easier way, no code envolved, simply by adding a content editor web part to the page with some javascript that will hide the field content form the user.

It is not perfect, sure. It can be fooled, right.
But for those of you that just need it for cosmetic reasons mostly, this is the perfect solution.

I actually covered that in an older post, I just think its title was not clear enough - please follow this link for the complete how-to manual.

Thanks, Shai.

Thursday, July 3, 2008

Creating a view for birthday

Well, I struggled with this for an hour or so until I finally found a solution...

our customer has a list of users with a date field with their Birthday.
He wishes to see the upcoming birthdays for users in the upcoming week.

The birthdate field holds the actual birthday of the user (i.e. July 24 1980), but he wants to see it as July 24 2008... July 24 2009... and so on.

Well, since we cannot use the [Today] field in calculated column (all tricks wont work - the field won't update!), I have conjured this solution that only asks for a yearly update to the column:

First, we have to create a calculated column that results in the current year birthdate
(from July 24 1980 to July 24 2008)

1 - create a date column to hold real birthday (named: BDay) or type date.
2 - create a calculate column to hold this year's BDay (named: YBDay).
3 - set the output type of the calculated value to "Date and Time"
4 - use this formula to generate its value:

Now, the rest is easy:
You create a view and set filter to 2 conditions:
where [this year birthday] >= [Today]
where [this year birthday] <= [Today] + 7

Now, you see all birthdays for the upcoming week!

Just remember - next year you will have to update the formula of the calculated field.

Hope this helps you - sure did saved me :)