Saturday, 7 July 2012

SPUnlock Tool "The file is locked for exclusive use by"

The file ""  is locked for exclusive use by domain\user
Normally you will get this when file from SharePoint library is in use in by any user in client applications that's as expected. But due to many reasons  this lock never get released even  when you are not using this file. 

SharePoint Lock and Checkout
 SharePoint lock are not same as item checkout. 

 is when user  perform through SharePoint UI for via programatically to edit a file 
 Checkout type
       Online :- The file is checked out for editing on the server.
     Offline :- The file is checked out for editing on the local computer.

Lock Type
When user open a document  in edit mode  in office client SharePoint Creates a short term  lock ( 10 min)  on the file, preventing other users from modifying it. this lock get renew by office client after every 10 min.
Lock Type 
        Exclusive: - The file is locked for editing by a single user. No other user can modify the file until the lock is released.
     Shared:- The file is locked for editing by a group who are using a collaborative application. Other users are prevented from modifying the file until the lock is released.

Note:- The checkout state of a file is independent of its locked state

Solutions for Sharepoint Accidental Lock 

  1. Wait for 10 min for lock to expire (this is true in 80 % of cases)
  2. Quick solution is to  reset  share point server ( not always feasible )
  3. Use a codeplex tool to unlock these file SPUnlock  (

SPUnlock Tool
Its a Sandbox based solution developed by me as an additional nice to have tool while working/ supporting  project issues where files get locked by user for some reason .

SPUnlock Tool Setup
  1. Download SPUnlockSandbox.wsp from
  2. Upload  SPUnlockSandbox.wsp to SP Site Collection Solution Gallery ( http:///sites//_catalogs/solutions/Forms/AllItems.aspx)
  3. Activate solution from solution gallery
  4. Confirm above step activate a  sitecollection feature "SPUnlockSandbox_Feature1" .
  5. Navigate to you site or any subsite  where and add webpart "SPFile Unlock"  to any page.
and there you go with this simple but useful tool 

Saturday, 14 April 2012

Info path 2010 on Ipad

From today I will be  working on rare combination of products Microsoft and Apple. to starts with Info path 2010 forms on I PAD browser . thanks to share point 2010 for having better html output to support multiple browser

Day 1 
1. Basic browser  infopath form works good in IPAD . thanks to SP 2010

Day 2
1. Will target application in two phase 1st create infopath application for client in windows system for offline capability  and online version (browser) for IPAD.
2. Phase 2 will add offline capability in IPAD. this going to be interesting  options here are
        a. Create or buy any infopath Ipad App like SharePlus
        b. Create a ipad app for application mean not a infopath but a ui application which will read and write infopath xml to sharepoint library . but downside of this is it will be specific to Application.

Day 3.
Notices a issue in info path browser forms in safari (IPAD)  not sure whom to blame MS or Apple.

You can't change text color or hi light a test with given ribbon controls. very minor issue .

I will skip some around 10 days it went smooth without any issue

Day 13
     Notices one more  issue in infopath browser form in Safari both  desktop and iPAD
       Description : My info path form have Submit button . when you hit submit button with some validation  error in form ( required field  validation) infopath will prompt a error popup . which is normal but once you are back to form  from error popup  last Rich text box field  which i was filling just before hitting submit button  will be blank.
     agian not sure whom to blame MS or Apple.

Wednesday, 11 April 2012

InfoPath Design Copy Past Issue

Today while working with infopath forms i feel sometime when I try to copy  and past some text or control across the view or to different location in a  same view it never past the content i have copyed. many people do system restart and it work but when i dig a bit its a strange dependency

if you close all your open  IE window  copy past starts working normally .

Don't know what this have to do with IE . but certainly there is some relation between  on IE and info path one more such example if if you make you your IE offline your info path will also get into offline mode .

Friday, 9 March 2012

Move SharePoint List Item (SPListItem) To Sub Folder

Below is a sample code to move SPlist item  from Root Location to sub folder. as every list item have unique url they can treated as File(SPFile). With SPFile Object we know how SPFile.Move() works.

In this sample code will try to move SharePoint list item from root folder to subfolder during ItemAdded Event.

* /Move  List Item to folder ( not Document library folder )
* with sahrepoint 2010(not sure if poosible in MOSS 2007 )
* Key point sahrepont create unique URL for every list item also . it will look like 
* http:///sites//Lists//1_.000    where 1 is SPitem ID
SPWeb web= properties.Web;
//Folder123 is Inside root location of List
string DestinationFolderName="Folder123";

// Source item outside folder Folder123 
SPListItem listitem = properties.ListItem;

SPFile listitemFile = web.GetFile(listitem.Url);

//Create New Destination  URL ../Lists/Folder123/1_.000
string NewDestinationUrl=listitemFile.Url.Replace(listitem.ID.ToString()+"_.000",DestinationFolderName+"/"+listitem.ID.ToString()+"_.000"); 

//Move Item Insite Folder123

Monday, 20 February 2012

Sharepoint 2010 Date Column Validation with [Today] Date

with new SP 2010 Column validation . 1st thought that came to my mind is date field validation with respect to today's date. then quickly create a date column TestDate and  and add the validation formula as below .
=[ TestDate ]>=[TODAY]

Then it will give you a error.
after some hit and trial I found actual expression should be
=[ TestDate ]>=TODAY()


Tuesday, 14 February 2012

WP e-Commerce digital product Download link on google checkout

When you are working with WP e-Commerce plugin for word press linked with Google Checkout for payment .and your shop is for  Digital Product and you feel you need more from this plugin then you are in right place . I have many issues  while configuring this plugin for one of my shop
1. Unable to display download link for digital products  after checkout .
2. No links to download digital product after Google checkout .
3  WP e-Commerce  add multiple  entries to  for single transaction
 4.Google checkout send Pending for shipping mail to user which in confusing .

the problem is plugin is not sending google information about the product . it just sends its pricing details.  to fix this go ahead and modify  phugins PHP files

Step 1 Go to Location "..\wp-e-commerce\wpsc-merchants"
Step2 . Open    GoogleCheckout-XML.php
Step 3. Go to Line number  182  ( just above   $cart->AddItem($cart_item); )
Step 4.Add below code to it just before  line $cart->AddItem($cart_item);
//Extra code  send media download url to google checkout  
   $siteurl = get_option('siteurl');
   $previous_download_ids = array(0);
   $product_id = wpsc_cart_item_product_id();
   $link = "";
   //$product_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='{$product_id}' LIMIT 1", ARRAY_A) ;
   $wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `active`='1' WHERE `product_id` = '$product_id' AND `purchid` = '{$purchase_log[0]['id']}'");
   $download_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_DOWNLOAD_STATUS."`
       WHERE `".WPSC_TABLE_DOWNLOAD_STATUS."`.`active`='1'
       AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`purchid`='".$purchase_log[0]['id']."'
       AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`product_id` ='".$product_id."'
       AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`id` NOT IN ('".implode("','",$previous_download_ids)."')",ARRAY_A);
     if(sizeof($download_data) != 0) {
      foreach($download_data as $single_download){
       if($single_download['uniqueid'] == null){// if the uniqueid is not equal to null, its "valid", regardless of what it is
        $link[] = array("url"=>$siteurl."?downloadid=".$single_download['id'], "name" =>$single_download["filename"]); 
       } else {
        $link[] = array("url"=>$siteurl."?downloadid=".$single_download['uniqueid'], "name" =>$single_download["filename"]);
   foreach($link as $single_link)
    // $product_list .= "\n\r ".$single_link["name"].": ".$single_link["url"]."\n\r";
    $cart_item->SetURLDigitalContent($single_link["url"], null, wpsc_cart_item_name());
      //End of extra code  Vijay
Step 4. Now you are done .

What the above line of code will do ?
1. Create entry in WPSC_TABLE_DOWNLOAD_STATUS table unique id for download url .
2. Activate the URL
3. Send download URL information to Google to be displayed in Google checkout page after transaction complete. user really dont have to come back to your site to get the download link
4. Along with download URL Google will treat this product as digital digital product so no shipping issue  .
5. on top of all these this download  url information will be there in Google checkout mail send to buyer .

I hope wp-ecommerce will add this oprion to there code .