Search This Blog

Monday, May 2, 2011

Hiding Workspace Checkbox while creating new sharepoint Event\Meeting

As per project requirement I was asked to hide a field called 'Workspace' from new event\meeting or editing existing event\meeting.  As 'Workspace' is a Cross Project Link type field so SPField.ShowInDisplayForm, SPField.ShowInEditForm etc do not work fine with this field. To fix that issue I put few lines of code in FeatureActivated() method:
 public override void FeatureActivated(SPFeatureReceiverProperties properties)
            SPWeb objSPWeb = (SPWeb)properties.Feature.Parent;
#region Disable Events\Meeting Workspace checkbox
SPList objSPListEvents = objSPWeb.Lists[Event_List”];
SPList objSPListMeetings = objSPWeb.Lists[Meeting_List”];
            if (objSPListEvents != null && objSPListMeetings != null)
SPField objSPFieldWorkSpace = objSPListEvents.Fields[“Workspace_Field”];
SPField objSPFieldMeetingsWorkSpace = objSPListMeetings.Fields[“Workspace_Field”];
if (objSPFieldWorkSpace != null && objSPFieldMeetingsWorkSpace != null)
            objSPFieldWorkSpace.Hidden = true;

            objSPFieldMeetingsWorkSpace.Hidden = true;
            catch (Exception ex)
                throw ex;

No comments:

Post a Comment