Yet another blog

Category Archives: Uncategorized

Capture only the Validation Rule Error message to display in VF page


I had a scenario where i have a VF page which saves records into a custom object. And i was having the controller code in a try catch block to capture the exceptions and was using the getmessage to display the error messages.

But this all the time spit out a lot of ugly stuff along with the error message

” Upsert Failed : First exception on row 0: first error;


All i wanted to show was that Quantity cannot be empty. thats exactly what the end user only wanted to know and all that crap of Upsert failed doesnt make any sense at all.

I had thought of capturing the error message in a string and split it with FIELD_CUSTOM_VALIDATION_EXCEPTION. then displaying the second item in the list to show the error message.

All this seem to be too complicated for this. Indeed there is something very simple to do this.

All you got to do is to add

<apex:pageMessages />

in your VF page. this will capture all your validation errors and diplay it.



error 14007:The requested lookup key was not found in any active activation context

If you are getting this error on trying to install any application

error 14007:The requested lookup key was not found in any active activation context

To sort this problem out you just need to run these 2 commands

%systemroot%\system32\msiexec.exe /unregserver
%systemroot%\system32\msiexec.exe /regserver

Hope this helps all those who encountered this problem

How to add www to sitemap links created by XML Sitemap Generator for WordPress

XML Sitemap Generator for WordPress  is a wonderful sitemap generator for wordpress platform. In one of sites when i posted the sitemap in google webmaster, i got an error  saying

Paths don’t match
We’ve detected that you submitted your Sitemap using a URL path that includes the www prefix (for instance, However, the URLs listed inside your Sitemap don’t use the www prefix (for instance,

This really was annoying coz, the blog was part of another site which is not on wordpress  but the sitemap generated had www prefixed and google had index over 700 pages of it. I was sure there was something in the settings that would make it add www.

Here is how i sorted it out

  1. Login to admin terminal (
  2. click on settings on the menu on the left.
  3. Click on general
  4. Change the WordPress address (URL) and  Blog address (URL) to include www 
  5. Save changes

This should create the sitemap to include www prefixed to the url.

Dont forget to manually rebuild the sitemap

Click on xml-sitemap under settings

Click on rebuild the sitemap link to manually rebuild the sitemap

If you changed something on your server or blog, you should rebuild the sitemap manually.

Verify if your sitemap now has www  prefixed.

Hope this helps

Dont forget to post your comments

redirecting using .htaccess

If you were to change your website to a new domain or changed the location of an existing file, and you have your url indexed by search engines. If the pages are redirected you could end up loosing a lot of traffic by users getting the 404 error.

You can sort those by using redirection. This can be achieved by http-equiv, javascript or by using some server side code. But the simplest way is by using .htaccess 301 redirect.

This method is search engine friendly and is the easiest way around.

Just add the following code to your .htaccess file placed in your old site.

Redirect 301 /olddirectory/oldfile.html

redirect 301 (the instruction that the page has moved)

/old/old.htm (the original folder path and file name) (new path and file name)

Test  immediately after implementing 301 redirects. If you find anything wrong, remove the redirect immediately.


Replace () is used to replaces all occurrences of a specified string value with another string value.


REPLACE ( string_expression , string_pattern , string_replacement )

Where string_expression is the string to be searched , string_pattern is the substring that needs to be searched and  string_replacement is the string which will replace the string_pattern

SELECT REPLACE(‘godisgreat’,’is’,’was’);

The output would be godwasgreat. It searched for the string “is” within the string “godisgreat” and replaced the occurance of “is” with “was”.

SELECT REPLACE(‘godisgreatis’,’is’,’was’);

The output would be godwasgreatwas.