Monday, July 30, 2012

Disable Publish button using Javascript

I wont suggest you to use the following approach to disable Publish button of a  NewItem.aspx page. The suggested approach is to configure security by excluding "Approve Items" permission for a permission level and assign it to SharePoint Group.


I agree that wont be the case every time - MyTeam faced same challenge today where we had a specific requirement to disable publish option from NewItem Page. Here is the quick and easy way to do it.


1. Save the following script in a .js file

<script language = "javascript"> 
varButtonClassName ="ms-ButtonHeightWidth"
varButtonClassName = new RegExp("(^|\\s)" + varButtonClassName + "(\\s|$)") ;  
varRibbonClassName ="ms-cui-ctl-large" 
varRibbonClassName = new RegExp("(^|\\s)" + varRibbonClassName + "(\\s|$)") ; 
varPublishText = "Publish"   
varPublishText = new RegExp("(^|\\s)" + varPublishText + "(\\s|$)")  ; 
elements = document.getElementsByTagName("*");  
for (var l=0, ll=elements.length; l<ll;l+=1)          
{                 
node = elements[l];     
if(varButtonClassName.test(node.className))    
   if(varPublishText.test(node.value)) node.disabled = true;     }    if(varRibbonClassName.test(node.className))    
   if(varPublishText.test(node.value)) node.disabled = true;     } 
} 
</script>
2. Upload the .js file into a library in the site
3. Edit NewItem.aspx from SharePoint UI and add a Content Editor Web Part  below the data entry web part
4. Edit the web part and refer the uploaded .js file to it
5. Save web part properties
6. Exit page edit
7. Refresh the  page ......... See the magic :) 

Sunday, July 29, 2012

Update created by column using powershell

Was busy in implementing a test site - my BA asked whether we can show the CEO's name instead of her name in the created by column of all items in a list.

$SPSite = New-Object Microsoft.SharePoint.SPSite("<site collection url>")
$SPWeb = $SPSite.AllWebs["<site name>"] 
$SPList = $SPWeb.Lists["<List Name>"] 
$SPListItemCollection = $SPList.Items 
$targetUser =$SPWeb.EnsureUser(“<user Windows ID>”)
foreach ($ListItem in $SPListItemCollection) 
    {   
        $ListItem["Author"] = $targetUser 
$ListItem.ModerationInformation.Status = "Approved"
        $ListItem.Update() 
    }
$SPWeb.Update()


Worked like a gem .... BA happy, CEO tooo :)

Thursday, July 26, 2012

Development options in SharePoint 2013

Looks like there are couple of new things introduced in SP2013 for development. On a high level the following are the development options available
  1.  SharePoint Apps
  2.  Mobile Apps
  3.  Reusable components
  4.  Classic farm solutions
  5.  Publishing sites
  • SharePoint Apps: Like ITunes apps, Android apps - SharePoint also introduce a new development option to develop stand alone solution having less features bundled together, installs/uninstalls easily. The new feature called corporate app catalogue would be the enterprise wide repository for apps and privileged information workers will be able to find and use it in their sharepoint sites. Per Microsoft Apps never runs on SharePoint servers - its logic always stays in cloud. Will share more details soon. I believe the components like lists, content types, custom pages, web parts, workflow will be right fit for apps.see my related post on app culture 
  • Mobile Apps : SP2013 introduce a client API for Windows phones, it can access SharePoint web sites and data. androids, i phones can use REST/OData end points for the same.
  • Reusable components : Microsoft claims VS2012 and SP2013 together can help developers to encapsulate and reuse app elements like code, script, markups etc.
  • Classic farm solution : Same old WSP based solutions that utilizes server object model code to perform admin tasks like timer jobs. 
  • Publishing Sites: SharePoint publishing sites provide large-scale content publishing with a high degree of maintainability and regulation compliance. They also provide management of documents, records, taxonomy, and content types.
More to follow...

Tuesday, July 24, 2012

Query that retrieve User Profile properties of a specific SharePoint 2010 user

Have you ever thought of a query that retrieve User Profile properties of a specific SharePoint 2010 user?


I have been searching for this guy for long ... today I found it.



SELECT  userprof.NTName,  proplist.PropertyName,  usrprofval.PropertyVal 
 FROM [<<ProfileDB>>].[dbo].[UserProfile_Full] userprof WITH(NOLOCK)
 JOIN  [<<ProfileDB>>].[dbo].[userProfileValue] usrprofval 
     ON  usrprofval.RecordID =  userprof.RecordID
 JOIN  [<<ProfileDB>>].[dbo].[PropertyList]     proplist  
     ON  proplist.PropertyID =  usrprofval.PropertyID 
WHERE  userprof .NTName = '<<windowsID>>'


Note: Reading from the SharePoint databases programmatically, or manually, can cause unexpected locking within Microsoft SQL Server which can adversely affect performance.

Monday, July 23, 2012

How SharePoint 2013 preview different from SP2010


This is the first in my series of blogs that compares new SP2013 preview with SP2010



  1. Web Analytics in SP2010 is discontinued and Analytical Processing for SharePoint 2013 is part of Search Service. Microsoft claims Scalability and performance improvements in its new avatar. Analytics processing component in SP2013 runs analytics jobs to analyze content in the search index and user actions. Looks like the analytics feature is more integrated with search features than an independent entity the way it is in SP2010. The other disappointing thing is the SP2010 analytics info like browser traffic, top users of a site, referring URL, quota usage analytics wont be available.
  2. Visual Upgrade is NOT available; replaced with much more comprehensive upgrade process called deferred site collection upgrade. Visual upgrade was limited to old master pages, css and html files but the new deferred site collection process the additional areas including SPFeature. There is no direct migration path from MOSS 2007 to SP2013. The Moss2007 site must move to SP2010 before upgrading to SP2013. Another thing the upgrade to SP2013 is irreversible. Due to All these constraints - Im doubtful about the success of this change.
  3. As part of simplifying the site template selection process, the following changes have been introduced
    • Document Workspace  site template has been replaced by the Team Site site template
    • All 5 Meeting Workspace site templates are not available. This looks like a strategic move to promote other Microsoft products like Lync (to conduct online meeting), OneNote (to capture Meeting notes), Team Site / MySites (to share meeting minutes etc). Microsoft annouces the existing site will  work till a major version release.
    • Personalization Site, Group Work Site, Visio Process Repository site templates have been removed because of less usage in SP2010. Microsoft annouces the existing site will  work till a major version release.
  4. Because of a design limitation - workbooks with external data connections that use Windows Auth cannot be refreshed in browser; you will be asked to open in excel client.
  5. Due to less usage , to reduce security issues and to simplify number of ways to connect SharePoint - The imaging web service for creating and managing picture libraries would be removed from next major release.
More to follow...

Sunday, July 22, 2012

sharepoint 2013 - databases behind the scenes

We all know - how the SQL server databases are related to SharePoint products and technologies. On releasing the SharePoint 2013 preview – let me try to create a ready reckoner for SharePoint databases

DB Category
DB Name
DB Name Syntax
Description
System DBs (Core DB)
Configuration
SharePoint_Config
Stores details about other SharePoint DBs, IIS web sites, web apps, trusted solutions, site templates and web app/farm settings.
Only one DB supported per farm
Central Admin Content
SharePoint_AdminContent_<GUID>
Centtral admin site's content database.
Only one DB supported per farm.
Content
WSS_Content_<GUID>
Stores all site content (list data, docs, web part properties, audit logs, user names, rights etc.)
Can contain more than one site collection data.
MS recomends the size to limit 200GB to ensure perfoemance. But can support upto 1TB if it’s a low IO system like Record Center.
Scale out to multiple DBs for a web app.
User Profile DBs
Profile
<UPSA>_ProfileDB_<GUID>
Stores and manages users and their social information
Synchronization
<UPSA>_SyncDB_<GUID>
Stores user profile configuration and staging data for use when profile data is syncd with directory services.
Social Tagging
<UPSA>_SocialDB_<GUID>
Stores social tags and notes created by users along with their URLs.
Search Service DBs
Search Admin
<SSA>_DB_<GUID>
Stores search application configuration and ACL for crawl component.
Analytics Reporting
<SSA>_Analytics ReportingStoreDB_<GUID>
Stores the results for usage analysis reports and extracts info from link DB.
Crawl
<SSA>_CrawlStoreDB_<GUID>
Stores the state of crawled data and crawl history
MS suggests add additional crawl DB per 10 mil items
Link
<SSA>_LinkStoreDB_<GUID>
Stores the info ie extracted by content processing component and click through info.
Growth: 1GB per 1mil docs ; 1GB per 1mil queries
Other Service App DBs
App License Management
AppMng_Service_DB_<GUID>
Stores the ap licenses and permissions that are downloaded from the Global Marketplace
Secure Store Service
Secure_Store_Service_DB_<GUID>
Stores and maps credentials such as accounts and password
Usage
WSS_Logging
Stores health monitoring and usage data temporaitly. It also used for reporting and diagnostics.
One usage DB per farm
Word Conversion
WordConversion_<GUID>
Stores information about pending and completed document conversion
Subscription Settings Service
SubscriptionSettings_<GUID>
Stores features and settings information for hosted customers.
sp 2013 (STD/ENT) Service App DBs
Word Automation Services
WordAutomationServices_<GUID>
Stores information about pending and completed document conversion
Business data Connectivity
BDC_Service_DB_<GUID>
Stores external content types and relate objects
Managed Metadata Service
<MMS>_<GUID>
Stores managed metadata and syndicated content types
Machine Translation Services
TranslationService_<GUID>
Stores info about pending and completed batch document translations
sp 2013 ENT Service App DBs
Project Server
<Project web App Content DB>
Store project and portfolio management data, time related data etc
PowerPivot Service App
<PPSA>_<GUID>
Stores data refresh schedules and PowerPivot usage.
This requires SQLServer 2012 analytical services (BI / ENT edition)
Taxonomy
<MMS>_<GUID>
Taxonomy related info
Performance Point Services
<PerfPointSA>_<GUID>
Stores temporary objects and persisted user comments and settings
State Service
<SS>_<GUID>
Stores temporary state info for inforpath forms services

Hope this helps J




Wednesday, July 18, 2012

Is SharePoint moving towards an App culture?


We are in a world of apps - yes you guessed it right Im talking about the stuff like Android apps , Iphone apps etc. After reading SharePoint 13 preview in Technet - I think SharePoint is also moving towards the App culture.. 


Architects/Developers like me have been building  server-side farm solutions that extend core SharePoint capabilities right from SharePoint 2003 (Im not sure wht was there prior to SPS2003). New SharePoint offers a new flexible development model that creates apps for SharePoint that take advantage of standard web technologies like JavaScript, OAuth, and OData. 


I believe the new app for SharePoint development model will extend the ability to build apps that take advantage of SharePoint capabilities and that run in the cloud instead of on our SharePoint farm. This flexible development model, along with the integration of standard web technologies, makes SharePoint development work more like other kinds of web development that we are already be doing. This change in philosophy would help the enterprises and users to discover, purchase and install sharepoint solutions quick and easy. The group benefited most out of this approach change is the solution providers who can simplify market and sell their solutions thru an app store - not necessarily Microsoft app store.
SharePoint Apps going to use the SharePoint client side techniques or REST to access SP entities and data. App for sharepoint cannot contain custom code that runs on Server and cannot call server object model APIs. In a nutshell App are for end users not for Admins.


The related major change we are seeing in SP13 preview is - deprecation of Sand-boxed solution (introduced in SP2010 - it was helping the site collection admins to manage solution of their own without touching farm servers)..

Tuesday, July 17, 2012

Whats there in new SharePoint

I was pretty excited to see latest version release of office suite 2013 along with new version of SharePoint.

Its catch word says SharePoint Server 15 enhances the workload experiences by enabling new compelling scenarios that engage and work with the user.

Had a quick look at Technet site and came to knew that the platform stays the same but few new things introduced....

Let me share few thing real  quick
  1. There are few  platform level improvements and new capabilities
    • Shredded Storage
    • SQL Improvements
    • Cache Service
    • Request Management
    • Themes
    • Sharing
  1. Content Management
    • Site-level retention policies was a pain point when we did Records Management for one of the Pharma major in SharePoint 2010 . Now the compliance levels extended to sites
    • The new  policies include - Retention policy for sites and Team Mailbox associated with site
    • This feature could help us the common business functions like Project closure and site level expiration policy
    • The discovery and legal hold feature were primitive in SP2010 – Microsoft claims there is exponential improvement in this area. Can’t wait to know it …
  1. Looks like there are handful of changes in Service applications  
    • (I’m yet to explore more details) there are New service applications available and improvements on existing ones
    • Office Web Apps is no longer a service application
    • Web Analytics is moved to part of search

I will detail more about customization, architecture in the upcoming posts