Posts

Showing posts from November 8, 2013

bind Lookup Field Value to a SPList Column

  SPFieldLookupValue   objLookupCategory  = new  SPFieldLookupValue (Convert.ToUInt16( ddlCategories.SelectedValue ), Convert.ToString( ddlCategories.SelectedItem.Text ));                                oConcItem ["Category"] =  objLookupCategory ;//Lookup  

check current user belog to whcich group in List Of Grops in A list Column

 using ( SPSite  site = new  SPSite ( SPContext.Current.Web.Url ))                               {                                   using ( SPWeb   objWeb  = site.OpenWeb())                                   {                                        SPList   oList  = objWeb.Lists["Kaizen Category"];                                            SPListItemCollection  results = oList.GetItems();                                            foreach  ( SPListItem  item in results)                                       {                                               string group = item["Category"]. ToString ();                                                SPGroup   groupName  = SPContext.Current. Web.Groups [group];////.Split('#')[1]                                                SPUser  user = objWeb.EnsureUser( objWeb.CurrentUser.ToString ());                                               if (

Start a Work Flow By Click on Button

  SPWorkflowManager   objWorkflowManager  = null;                                                  SPWorkflowAssociationCollection   objWorkflowAssociationCollection  = null;                                                  objWorkflowManager  = listitem.Web. Site.WorkflowManager ;                                                  objWorkflowAssociationCollection  = listitem.ParentList. WorkflowAssociations ;                                                      foreach  ( SPWorkflowAssociation   objWorkflowAssociation  in  objWorkflowAssociationCollection )                                                 {                                                     web.AllowUnsafeUpdates = true;                                                     objWorkflowManager.StartWorkflow( listitem ,  objWorkflowAssociation , objWorkflowAssociation.AssociationData, true);                                                     web.AllowUnsafeUpdates = false;        

checking that user belongs to particular Group are Not

it is used to find the current  loged  in user belongs to 1 particular group are not...    private  bool   CheckKaizenMentor (string  groupName )           {                bool   userVal  = false;               SPSecurity.RunWithElevatedPrivileges(delegate()                 {                     using ( SPSite  site = new  SPSite ( SPContext.Current.Site.Url ))                     {                         using ( SPWeb  web = site.OpenWeb())                         {                             //For getting the Group Users for Kaizen mentor radio button list.                              SPGroup   kcUsers  = web.Groups[ groupName ];                              foreach  ( SPUser  user in kcUsers.Users)                             {                                 if ( currentUser  == user.LoginName)                                 {                                      userVal  = true;                            

Getting User Profile

 private void  GetUserProfile ()           {                   try               {                   using ( SPSite  site = new  SPSite ( SPContext.Current.Site.Url ))                   {                       using ( SPWeb  web = site.OpenWeb())                       {                           web.AllowUnsafeUpdates = true;                                SPServiceContext   oSPServiceContext  = SPServiceContext.GetContext(site);                            UserProfileManager   upm  = new  UserProfileManager ( oSPServiceContext );                            SPUser   spUser  = null;                           if ( Request.Params ["ID"] != null)                           {                                spUser  = web.EnsureUser("DC\\" + lblKaizenOwnerValue.Text);                           }                           else                           {                                spUser  =