Tuesday, August 27, 2013

SharePoint Event receiver triggering for all list .Need to trigger for only one list or one type of list

Hi one of the most common requirement in SharePoint is to have event receiver attached to a list .But when you add a event receiver item in Visual Studio and deploy .It will be attached to all the list .

Below are the few things you need to follow to attach a Event Receiver to particular list in SharePoint

1)In the Element.xml of Event Receiver change the tag property as below

         <Receivers ListUrl="Lists/List1">

This will attach the Event Reciever to only List1


2)Changing the tag as below

        <Receivers ListTemplateId="10001" >

will attach the Event Receiver to all the list in site which as listTemplateID =10001

These id are found when you create a list definition by yourself through Visual Studio.
Follow  this link Default list template Id to know about default list id of share point list.


Even after doing this few people see that Event Receiver is been attached to all the list .

The main reason for this is the Feature which is trying to activate the Event Receiver is at Site scope it has to be always at Web scoped . If it at Site scoped the ListUrl and ListTemplateId will be overridden and it will be attached to all the list in the site.

Monday, August 19, 2013

Add data to people picker in Visual webpart programatically - sharepoint 2010

Add the People picker field in the ascx file as below

 <SharePoint:PeopleEditor runat="server" ID="peoplePickerID" MultiSelect="true" 
SelectionSet="User" />

in the code behind on page load write the logic to fill teh people picker from a list having a
people/group type column.


ArrayList PickerEntities = new ArrayList(); 
SPFieldUserValueCollection fieldUserValueCollection = (SPFieldUserValueCollection)item["PeopleGroupTypeColumnDispName"];

            foreach (SPFieldUserValue spuserval in fieldUserValueCollection)
            {
                SPUser userToassign = spuserval.User;
                PickerEntity entity = new PickerEntity();
                PeopleEditor pepEditor = new PeopleEditor();
                entity.EntityData["AccountName"] = spuserval.User.LoginName;
                entity.EntityData["SPUserID"] = spuserval.User.ID;
                entity.EntityData["Email"] = spuserval.User.Email;
                entity.Key = spuserval.User.LoginName;
                entity.Description = spuserval.User.LoginName;
                entity.DisplayText = spuserval.User.Name;
                entity = pepEditor.ValidateEntity(entity);
                entity.IsResolved = true;
                PickerEntities.Add(entity);
            }

peoplePickerID.UpdateEntities(PickerEntities);

 *item["PeopleGroupTypeColumnDispName"];--> is list column of people/group type


Have a look at other post about client people picker of Sharepoint 2013
Client people picker-Sharepoint 2013 



 

Wednesday, August 7, 2013

SharePoint 2013 Workflow

The concept of Workflow in SharePoint 2013 is changed a whole lot.

The three thing which you need to take care while configuring the workflow to run on SharePoint 2013 is that

  1. Workflow Manager 1.0
  2. Workflow client 1.0
  3. Workflow Manager Tool for Visual 2012
  4. Developer Tools for Visual studio.

As the Workflow does not run inside the share point  you can install Workflow Manager 1.0  on different server or on same server where share point is hosted ..You can follow the MSDN link below to install and configure the Workflow Manager 1.0.

http://technet.microsoft.com/en-us/library/jj658588.aspx

Workflow client 1.0 - This has to be installed on all the sharepoint server (Web fornt end,App).This has API which communicates with the Workflow Manager.

Workflow Manager Tool for Visual 2012 - This has to be installed on the server where you create Visual studio 2013 SharePoint Workflow.Assuming that VS2012 is already installed .
2013 Sharepoint WF template is named as "Workflow"  in VS the "sequential and state machine" template is legacy now and it is not used in SharePoint 2013.

Developer Tools for Visual studio- Is to be installed on server where the Visual studio 2012 is installed.This provide new activities in Tool Box of VS12.


Along with this when you try to install the WorkflowManager through webPlatform installer .
Service Bus and cummunlative updates will be installed automatically.If you are installing it manually you need to install all the updates and Service bus.


Even after having all this there will be few problem with sending mails from VS12 WF.To overcome the issue You need to Install the MARCH-PU sharepoint 2013 updated and configure the same.


Plese follow the below link to install and configure it

http://www.deliveron.com/blog/post/Installing-March-2013-Public-Update-on-SharePoint-Server-2013.aspx


After all these are done you also need
  • App Management Service to be running
  • User Profile Service to be running
  • User Profile Sync Service to be running
Only then your WF runs without any problem :)