Visit our SharePoint Forum

SharePoint developer? Submit Yourself as Freelancer

Friday, July 30, 2010

Approval workflows in SharePoint Designer 2010 Tutorial

Here is a 10 min video to learn, how to create and customize approval workflows in SharePoint Designer 2010. You’ll also learn how to customize the associated forms, task outcomes, and every event in the overall task process.
Create approval workflows in SharePoint Designer 2010 -

Check User Permission in Sharepoint Designer 2010 workflow

In SharePoint 2010 Designer workflow the User-Impersonation type step has some additional conditions available for checking list and item level permissions for a specified
Lets look at two major conditions that you would need to implement impersonation -

1. Check list item permissions - The condition simply says the below :
If permissions for these users are at least these permissions on item in this list.

The usage : If permissions for WFApprovers Members are at least Read on item in Current Items
For the above condition to evaluate as true, the users must have at least the permissions that the Read Permission levels provide. This step can very well be used to check that the WFApprovers should have read access to the items.

2. Check list item permission levels - The condition simply says the below :
If permission levels for these users are at least these permission levels on item in this list.
The usage : If permission levels for ikapoor Members are at least Read on item in Current Items.
Please note that : The users can be a single user, multiple users, but you cannot use a group in this condition.
Important Things to remember Notes : Impersonation steps can only be added to the root of a workflow and cannot be nested in another step.

Monday, July 26, 2010

Get Item level Permissions using Client Object model SHarePoint 2010

Here is a little code snippet to get the info about the users who have permission for a specific item in a list

Retrieving permissions for a Specific item -

private void GetItemPermission()
{
SecurableObject curObj = null;
ListItem curItem = ctx.Web.Lists.GetByTitle(“My List”).GetItemById(ItemId); -> Use ItemId of the Item.
//plug it into our query objectcurObj = curItem as SecurableObject;
IEnumerable roles = null;
roles = ctx.LoadQuery(
curObj.RoleAssignments.Include(
roleAsg => roleAsg.Member,
roleAsg => roleAsg.RoleDefinitionBindings.Include(
roleDef => roleDef.Name, // for each role def, include roleDef’s Name
roleDef => roleDef.Description)));
ctx.ExecuteQuery();
}

Tuesday, July 20, 2010

Programmatically access user profile + client object model SharePoint 2010

Here is a Code snippet for retrieving user profile picture using Client Object model – ECMAScript . I am passing the userId from the front end to a javascript method called “getUserProfile()” to retrieve the user profile info. The method onQuerySucceeded will get you the user Profile info.

function getUserProfile(userID)
{
var clientContext = new SP.ClientContext.get_current();

var web = clientContext.get_web();

var userInfoList = web.get_siteUserInfoList();

var camlQuery = new SP.CamlQuery();

camlQuery.set_viewXml(‘<View><Query><Where><Eq><FieldRef Name=\’ID\’/>’ +’<Value Type=\’Number\’>’ + userID + ‘</Value></Eq>’ +

‘</Where></Query><RowLimit>1</RowLimit></View>’);

this.collListItem = userInfoList.getItems(camlQuery);

clientContext.load(collListItem);

clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
}

function onQuerySucceeded(sender, args)
{

var item = collListItem.itemAt(0);

var profile = item.get_item(‘Notes’);

var pictureUrl = item.get_item(‘Picture’).get_url();

var userImage = document.getElementById(‘myImageContainer’); -> Image object

userImage.src = pictureUrl;

var profileDiv = document.getElementById(‘userProfileContainer’);

profileDiv.innerHTML = profile;
}

Friday, July 2, 2010

Change Master page for logged in user SharePoint

This is probably the most asked questions related to sharepoint branding and customization. In this post we will discuss how you can change the master page for your site according to some logic like you can change the master page for a logged in user or simply can switch the application.master page to your custom master page for all applictaion pages.

I ahve written a Step-by-step sample code to switch mater page according to logged in user's group. See the Post @ Switch SharePoint master page for logged in user

SharePoint Programming