Posts

Showing posts from January, 2013

How to get Relative Path of SharePoint site in JavaScript

Just add following lines and use the variable... var siteCollectionUrl = _spPageContextInfo.siteServerRelativeUrl;​ var siteWebUrl = _spPageContextInfo.webServerRelativeUrl; The following blog explained in detail about _spPageContextInfo object . http://blog.tedpattison.net/Lists/Posts/Post.aspx?ID=9

Create custom permission levels and groups using PowerShell

$siteUrl =  Read-Host "Enter Site Collection URL:" $siteUrl = $siteUrl.Trim(); $site=Get-SPSite $siteUrl $web=$site.RootWeb; write-host "Connected to the site successfully..." write-host "Step 1: Creating custom permission level: Admin" $plAdmin=New-Object Microsoft.SharePoint.SPRoleDefinition $plAdmin.Name="Admin" $plAdmin.Description="Custom Permission Level to manage application" $plAdmin.BasePermissions="EmptyMask, ViewListItems, AddListItems, EditListItems, DeleteListItems, ApproveItems, OpenItems, ViewVersions, DeleteVersions, CancelCheckout, ViewFormPages, Open, ViewPages, AddAndCustomizePages, ApplyThemeAndBorder, ApplyStyleSheets, ViewUsageData, ManagePermissions, BrowseDirectories, BrowseUserInfo, AddDelPrivateWebParts, UpdatePersonalWebParts, UseClientIntegration, UseRemoteAPIs, ManageAlerts, CreateAlerts, EditMyUserInfo, EnumeratePermissions" $web.RoleDefinitions.Add($plAdmin); write-host "Ste...

Creating groups and adding users to the groups using PoweShell

When you are moving your site to production environment as a single click deployment package instead of site backup and restore you will be required to write scripts to achieve certain functionality. One is creating custom groups and adding users to that groups. The following Power-Shell script will be used to achieve this. First we will create one xml file where it contains list of all groups and users in the given format. <? xml version = " 1.0 " encoding = " utf-8 " ?> < Groups >   < Group name = " Directors " description = "" >     < Users >       < User > Domain\director1 </ User >       </ Users >   </ Group >    < Group name = " Coordinators " description = "" >     < Users >       < User > Domain\coordinator1 </ User >     </ ...

Show Tool Tip in SharePoint on Column when Mouse Over

Requirement : We had an requirement whereby tool tip should be displayed on mouse over of one SharePoint columns. Tool tip should show data from other column. User can change tool tip data anytime and tool tip should reflect it. Solution : Create a SharePoint Designer page to modify XSLT and call Tip() and UnTip() function. See below... For Static text this can be done using Content Editor Webpart. <script type="text/javascript" language="javascript" src="/wz_tooltip.js"></script> <a href="#" onmouseover="Tip( '{@Customer_x0020_Traction_x0020_Re}' );" onmouseout="UnTip();"> You can find more information about this tooltip script in the below link. http://www.walterzorn.de/en/tooltip/tooltip_e.htm

Manual validation with asp.net validation controls

You all know that asp.net validation controls are automatically validated when you set property CausesValidation=true for a button. But sometimes we will be required to do manually/explicitly. I came across with this situation. That is, on button click I need to execute some JavaScript code if all validations are passed. The problem here is both validations and JavaScript code will not get executed same time. In this case what I did is, I set CausesValidation=false  for a button and added the following JavaScript code to do manual validation. function checkValidations() {      var rtnVal = true ;      for (i = 0; i < Page_Validators.length; i++) {          ValidatorValidate(Page_Validators[i]);           if (!Page_Validators[i].isvalid) { //at least one is not valid.              rt...