Wednesday, September 10, 2014

Vanila Mask Java Script Library to mask the input based on type.

I found a beautiful JS plugin which gives the developer option to mask the in input based on type of input you specify for a text box.

It can be

  1. Date
  2. Phone Number
  3. Car Plate number etc...
Here is the link to the site.

Wednesday, May 29, 2013

How to SHRINKFILE and TRUNCATEFILE in SQL Server 2008.

http://www.codeproject.com/Articles/261132/Truncate-Shrink-Transaction-Log-files-on-SQL-Serve

Updated working Script


 --Step1--  
 CREATE TABLE #TransactionLogFiles (DatabaseName VARCHAR(150), LogFileName VARCHAR(150))  
 INSERT INTO #TransactionLogFiles (DatabaseName, LogFileName)  
   SELECT b.[name], a.[name]FROM sys.master_files a  
   JOIN sys.databases b  
   ON a.database_id = b.database_id  
   WHERE a.[type] = 1 AND b.[name] NOT IN ('master','tempdb','model','msdb')  
     
   --Step 2 --  
     
   DECLARE @DataBase VARCHAR(128)  
 DECLARE @SqlScript VARCHAR(MAX)   
 -- step 2. insert all the database name and corresponding log files' names into the temp table  
 DECLARE DataBaseList CURSOR FOR   
 SELECT DatabaseName, LogFileName FROM #TransactionLogFiles  
 OPEN DataBaseList FETCH  
 NEXT FROM DataBaseList INTO @DataBase  
 WHILE @@FETCH_STATUS <> -1   
 BEGIN  
   
 SET @SqlScript = 'USE [' + @DataBase + '] INSERT INTO #TransactionLogFiles(DatabaseName, LogFileName) SELECT '''  
 + @DataBase + ''', Name FROM sysfiles WHERE FileID=2'  
 --SELECT @SqlScript  
 EXEC(@SqlScript)   
 FETCH NEXT FROM DataBaseList INTO @DataBase END  
   
 DEALLOCATE DataBaseList  
 --Step 3 --  
 SET @SqlScript = ''  
 DECLARE TransactionLogList CURSOR FOR  
 SELECT DatabaseName, LogFileName FROM #TransactionLogFiles  
 DECLARE @LogFile VARCHAR(128)  
    
 OPEN TransactionLogList FETCH  
 NEXT FROM TransactionLogList INTO @DataBase, @LogFile  
 WHILE @@FETCH_STATUS <> -1  
 BEGIN  
 SELECT @SqlScript = @SqlScript + 'USE [' + @DataBase + '] '  
 + 'ALTER DATABASE [' + @DataBase + '] SET RECOVERY SIMPLE WITH NO_WAIT '  
 + 'DBCC SHRINKFILE(N''' + @LogFile + ''', 1) '  
 + 'ALTER DATABASE [' + @DataBase + '] SET RECOVERY FULL WITH NO_WAIT '  
    
 FETCH NEXT FROM TransactionLogList INTO @DataBase, @LogFile END  
 DEALLOCATE TransactionLogList  
 EXEC(@SqlScript)   
   
 -- step 4. clean up  
 DROP TABLE #TransactionLogFiles  

Tuesday, April 2, 2013

Simple Powershell Script to take backup of all site collections in all webapplications in a farm


$webapps = Get-SPWebApplication
foreach($app in $webapps)
{
    $siteCollections = $app.Sites
  
    foreach($sc in $siteCollections)
    {
        $loc="c:\Backups_sitecolls\"+$sc.Url.Substring(7).Replace(':','')+".bak";
        $loc=$loc.Replace('/','_');
        "backing up " + $sc.Url
        Backup-SPSite -Identity $sc.Url -Path $loc -Confirm -Force -NoSiteLock
      
    }
}
This script clears the http:// section of url and replaces and replaces / with _ in the file name of site collection.
This needs a folder "c:\Backups_sitecolls\".
Replace : before port number with empty character.

Thursday, July 26, 2012

Custom Themes, Master Pages, Background Images and Font settings made easy in SharePoint 2013.

            This week i was playing with the SharePoint 2013 space. (Thanks to my Friend and Colleague Atul).

When i was checking for the Changes in Site Settings I observer few additions.

The best thing that i observed is

Composed Looks


Which takes you to the screen.


And you will find the list of all the available Composed looks which will have

Properties

  1.  Name (Name of Compose Look).
  2. Master Page URL
  3. Theme URL
  4. Image URL
  5. Font Scheme URL
  6. Display Order
Where you can provide the link to files that you want to use in your custom Composed Looks.

you can save the local copy of 
  • .spcolor
  • .spfont
files and edit them (They are nothing but plain XML Files). upload them and use them in your custom looks

see the below files .





I feel this is a very neat new feature in new version.

Courtesy: http://www.sharepointdesignlabs.com/blog/Lists/Posts/Post.aspx?ID=16

Wednesday, June 20, 2012

No Author (Created By) Field in SPList.getItems(SPQuery).

Hi,

I assume that you all know that all the list items can be retrieved from SharePoint List using

SPList.getItems(SPQuery)

And returns all the items based on user permission and Filter that were specified in query. The columns that it return by default (For a document library) are

FileLeafRef
Title
ID
ContentType
Created
Modified
_CopySource
_CheckinComment
LinkFileNameNoMenu
LinkFilename
DocIcon
FileSizeDisplay
ItemChildCount
FolderChildCount
Edit
_UIVersionString
ParentVersionString
ParentLeafName
CheckoutUser
Editor

And Author.

The reason why i mentioned Author separately is because GetItems() method return Author Filed only for SiteCollection Admins and application pool admins. 
 
Regual user like site administrator, modifiers, visitors will not get that column.
 
If you are trying to get datatable from GetItems() method and use a custom column that shows Author (created By) column make sure to user elevated privileges based on your need.

Tuesday, April 24, 2012

Custom People Picker

Nice article to build Custom People Picker.


http://sharepointsolutions.com/sharepoint-help/blog/2009/10/create-a-custom-picker-in-sharepoint-2010/

Tuesday, March 20, 2012

Error Compiling SharePoint Workflow in Dev Server.

If any one of have problem compiling the SharePoint 2010 Workflow (Sequential and State Machine) in you Dev Server. And if the Error is this


Even for the empty workflow its giving this error.
Error 1 The "CompileWorkflowTask" task failed unexpectedly.
System.NotSupportedException: The given path's format is not supported.
   at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
   at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
   at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
   at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
   at System.IO.Path.GetFullPath(String path)
   at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
   at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension, Boolean keepFile)
   at System.Workflow.ComponentModel.Compiler.CompileWorkflowTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) stateWorkflow1

Check this Thread in MSDN Forum.


http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/74975cb4-20f9-4a3f-bb41-74382eecc5bb/#dd666781-46fb-4bb2-b8e8-cf49a4ebfa4b 

Wednesday, September 21, 2011

Look up columns problem with List Templates.

When we try to recreate the lists with look up columns from one site to another site, we lose the look up connection.

For example if have two sites 

A and B

A has list called A1 which has a look up column referring List AL1

If you want to take a copy of list A1 and recreate it in site B as B1 with look up referring to BL1.

Follow these steps

  1. Save List A1 as template (.stp).
  2.  Go to site collection settings.
  3. open the list template gallery.
  4. Save the A1's template in your computer.
  5. Go to the .stp file saved in you computer.
  6. change its extension to .cab 
  7. open the ziped file and extract the files in it to a folder.
  8. Open the manifest.xml file in notepad (or any other text editor).
  9. search for the GUID of list AL1 and replace it with GUID or BL1.
  10. save the manifest.xml file
  11. open command prompt and type the command "makecab manifest.xml template1.stp".
  12. It creates the template1.stp file.
  13. Upload template1.stp to the site collection of B site.
  14. create the list B1 using template1.stp.
  15. If you have multiple look up fields repeat the step 1 to 14 for all those fields.



If this is post is helpful, please leave a comment. Thanks.