Loading...

Thursday, September 13, 2012

Role Based Navigation:Role Based QuickLaunch

Its the common requirement  everywhere to create the RoleBased QuickLaunch and Global Navigation
Following code snippet hides the Firstnode of Quick Launch for Users other than owners and admins,
To implement this
Edit the Master Page in SPD and add this css along with SPsecurity Trimmed Control in head section of master page(Only in following sequence)

1)Following css will be available for all users

<style type="text/css">
/* mainlinks */
.menu-vertical > ul.root > li.static:first-child > .menu-item{

display:none;
}
/* Sublinks */
.menu-vertical > ul.root > li.static:first-child   > ul.static  {

display:none;
}

</style>
2)Following css will be only  available for Owners/admins

<SharePoint:SPSecurityTrimmedControl ID="sitePerms" PermissionsString="ManageWeb" runat="server">
 <style type="text/css">
 /* mainlinks */
.menu-vertical > ul.root > li.static:first-child > .menu-item{

display:block;
}
/* Sublinks */
.menu-vertical > ul.root > li.static:first-child   > ul.static  {

display:block;
}

 </style>
</SharePoint:SPSecurityTrimmedControl>


For extensive branding of QuickLaunch following links are very useful

To Deploy , create the feature to replace the existing master page


Sunday, September 9, 2012

How To Create Solution Package To Deploy Lists With Lookup Columns

To save the time and work pressure,Some of the developers end up deploying lists by 'Save As Template' method.
My request to all those developers is not to go by that way(specially for new learners). Just take the advantage of ,What feature MS Visual Studio 2010 for SharePoint provides.
 Because there are several disadvantage of this ('Save as Template') method. and When it comes for the lists with Parent-Child relationship which includes lookup column it's terrible.
Not only for this post,think of deployment perspective while finalizing any approach for development.
To Develop solution package for Lists With Lookup Columns
A)Create Content Type and Site Columns for Parent List 
1)Navigate to any source SharePoint site.
Site action -->Site Settings-->Site Columns Create site column 'Parent Column' with Single line of Text

Now add this site column to Parent Content Type,
to do so,create new Content Type which inherits from List Content Type and add parent column

2)Create Custom List ParentList  and Enable management of Content Type of this List(List Settings 
-->Allow management Of Content Type
Add from existing  Site Content Type and Select Parent Lookup Content Type
and delete the existing Item Content Type

B)Create Content Type and Site Columns for Child List
 Site action -->Site Settings-->Site Columns Create site column 'Foreign Column' with Lookup Type as described in below image
  
  Now add this site column to Child Content Type  and Associate this content type with Child List in the similar way , as that of Parent List(As described above in Section A )

C)Get the wsp file of the site and Import to Visual Studio
1)Browse to _Layouts/savetmpl.aspx with include contents check box checked and save it to the local disk(this link is not visible for publishing sites in site settings)
2)Visual Studio 2010-->run as admin-->New Project-->SharePoint-->Import Solution Package.
Select deploy as Farm solution and select the wsp saved in above in Step  C 1.
Press Shift on Keyboard,select first and last row and uncheck all the files shown in grid
Now you have to be very careful.Make sure that following items are selected before clicking on next
1)Parent Column, Foreign Column(Child Column) site columns
2)Parent Content Type and  Child Content Types
3)Parent List Instance and  Child List Instance
4)ListParentList_Pages and ListChildList_Pages

On clicking Finish ,If you get Popup for  dependencies,Click on 'No'  and Solution should appear like below

Please add to the comments If you get any deployment errors.while doing this activity. I renamed the Child List before Importing.so I got the deployment errors for List not found .Then I ran replace all for new list name and Its working now :)

If during deployment few more columns and Content type needs to be deployed , get  the schema  through powershell add to this solution.

Download Source

Monday, August 27, 2012

SharePoint Designer Errors

When SPD throws the nasty errors like below and  which points to no hint, then there is only one way.
Restart the IIS and remove the temporary files :)

soap:ServerException of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.Attempted to read or write protected memory. This is often an indication that other memory is corrupt. (This Post could save the time of people).

This error could occur due to memory leakage.so make sure that object is properly disposed .
Restarting IIS can resolve this issue but It may occur again If the memory leakge is not handled
 Verify memory leakage scenarios here

Updating lookup table in Project server 2010

Following is the code snippet for updating lookup table value in project server 2010

using PSLibrary = Microsoft.Office.Project.Server.Library;
using Updatelookup.WebSvcLookup;
using System.Net;
using System.Data;

namespace Updatelookup
{

class Program
{

static void Main(string[] args)

{
LookupTable tblLookup = new LookupTable();
tblLookup.Url = "pwaurl" + "/" + "_vti_bin/PSI/LookupTable.asmx";
NetworkCredential prjCdn = new NetworkCredential("user", "pwd", "domain");
tblLookup.Credentials = prjCdn;

AddToLookupTB(tblLookup, "Customer");

}


static void AddToLookupTB(LookupTable tblLookup, string TableName)

{
LookupTableDataSet lookupDs = new LookupTableDataSet();

//Get all the lookup table

//Get lookup table guid
lookupDs = tblLookup.ReadLookupTables("", false, 0);//
DataView dvLookup = new DataView(lookupDs.Tables["LookupTables"]);
dvLookup.RowFilter = "LT_Name = '" + TableName + "'";
DataTable lookupValueTB = new DataTable();

lookupValueTB = dvLookup.ToTable("LookupTable");
Guid LookupgId = new Guid(Convert.ToString(lookupValueTB.Rows[0]["LT_UID"]));

//Read lookup table dataset
Guid[] ltGuids = new Guid[] { LookupgId };
LookupTableDataSet LTCustomer = tblLookup.ReadLookupTablesByUids(ltGuids, false, 1033);
LookupTableDataSet.LookupTableTreesRow drLT_TREE = LTCustomer.LookupTableTrees.NewLookupTableTreesRow();

//Add new lookup value
drLT_TREE.LT_UID = LookupgId;
drLT_TREE.LT_STRUCT_UID = Guid.NewGuid();
drLT_TREE.SetLT_PARENT_STRUCT_UIDNull();
drLT_TREE.LT_VALUE_TEXT = "Customer 3";
drLT_TREE.LT_VALUE_SORT_INDEX = (byte)PSLibrary.LookupTables.SortOrder.Descending;
( here I checked the orginal order of values in lookup table by Navigating server settings--> Lookup table-->Customer lookup table and made ensure that order given there and in mentioned in above code line is same .)
LookupTableDataSet newLTDs = LTCustomer.GetChanges() as LookupTableDataSet;

tblLookup.CheckOutLookupTables(ltGuids);
tblLookup.UpdateLookupTables(newLTDs, false, false, 1033);
tblLookup.CheckInLookupTables(ltGuids, false);

}}}

Wednesday, August 8, 2012

Enterprise Project Management:Project Site Approval Workflow in Project Server 2010 -- Part - II

i)To Deploy the project site workflow on PWA and configure Workflow Stages with PDP pages.
Get the deployment steps @Codeplex 
ii)To create project site workflow Read this post

Wednesday, July 18, 2012

OOB Table Of Contents WebPart To Show All Subsites


1)Edit the LevelStyle.xsl  file in In Top Level site\All Site Contents\Style libray to Show only sites and not the other libraries .


Edit the webpart properties as per the requirements

2)To Show All sites
Top Level site or the Site for which you need to display all subsites--Site actions -->Site settings -->Look and Feel-->Navigation -->Increase value

















3)Add the TOC webpart (Edit Page-->Insert Webpart-->Select Content Rollup )
 4)Set the number of levels to one.(Edit Webpart-->Set Properties as below)
 This WebPart can be used as OOB Navigation WebPart through out the site.
This is one more useful blog most ,If more customization is required
Note -->TOC Webpart can dispaly navigation only in single site collection