Sharepoint Workspace EventHandling - sharepoint

I want to capture the Event when a User Deletes a WorkSpace /Site , I have to perfomr some Action.
how to capture the Website deletion Event?

You can use the WebDeleting event, this has to be added to a web by a feature recevier (it is not possible to do this declaratively in CAML in a site definition for instance).
Just create a feature and activate that on the sites invvolved.
It is also possible to use SEventReg, more information here:
SEventReg

Related

Create EventReceiver when new site collection is created in SharePoint 2010?

I need a way to execute code when a new Site Collection is created. I've looked at creating a web-scoped FeatureReceiver that gets executed when a new Web is created. Then stapling this feature to all the site definitions, however Visual Studio 2010 isn't letting me deploy the module that contains the FeatureSiteTemplateAssociation directive. It complains that the feature can't be deployed farm level (because it contains a Module).
Any ideas?
It sounds like you might want to use an Event Receiver instead of a Feature Receiver. There is only an event for determining if a site collection is deleting/deleted. There is an event for Web Adding/Provisioned however. If you are creating a site immediately after creating the site collection one of those 2 events could be used to simply check the count of webs in the collection (0 or 1 depending on which web event receiver you use). This would essential run your code on the creation of the first site within the site collection and should accomplish what you are looking for.

Prevent users from Activating features in Sharepoint

If I deploy a solution at farm level, is there a way by which i can prevent the owners of the various site collections from activating the features present in that solution?
A simple way to prevent site collection users from activating a certain feature is to mark it as hidden. These features are then effectively only allowed to be activated by farm administrators through STSADM commands.
To hide a feature update the Hidden attribute of the Feature element to ‘TRUE’ as shown below:
<Feature
Id="AD2146D-62DA-4911-DBC1-AE177DE40084"
Title="Restricted Web Parts"
Hidden="TRUE"
.../>
Alternatively if you are using SharePoint 2010 you can use Feature Packs to solve this problem by targeting a set of features to a particular set of users.
Have a look at the Zevenseas feature blocker.
If an error occurs during feature activation, it will not activate the feature and will retract any effects which might have been deployed as part of the Elements Manifest.
So, through crafty usage of this, you can use the FeatureActivated portion of a feature receiver to check who is activating it, and throw an UnauthorizedAccessException with an appropriate error message detailing why the feature cannot be activated. This will show up as the standard SharePoint error page with the message you specify. If you already have a feature receiver on the feature, you need to append this at the start of the FeatureActivated portion, so that any programmatic actions don't occur (unlike elements manifest, these are not retracted on unsuccessful activation).
If you haven't used a Feature Receiver before, you just need two parts to establish it.
In the feature XML of your feature, add the following two attributes to the Feature node.
ReceiverAssembly=(four-part-assembly-string)
ReceiverClass=(full namespace.class name of receiver class)
Write a receiver class. This inherits from SPFeatureReceiver, and has 4 required overrides in FeatureActivated, FeatureDeactivating, FeatureInstalled, and FeatureUninstalling. You don't have to do anything for the last 3. You'll write your security check in the FeatureActivated method.

sharepoint Feature Stapling, after page is created?

I have been adding lists and sites to sites when they have been created with feature stapling. Now I want to add a web part when a site is created but it seems like it is to early to do that in FeatureActivated() when I am using feature stapling.
It is working when I activate a feature for an already created site but when I try to do it with feature stapling a get an exception that the object is not created.
Do you know any why to accomplish this when the site is created?
Make sure you use the SPLimitedWebPartManager to perform this work, or you will have trouble.
I've been looking at Microsoft's own early example of how to build solutions - the GroupBoard Workspace solution (http://technet.microsoft.com/en-us/windowsserver/sharepoint/bb848080.aspx)
In this case they actually have two solutions - one which creates the site and another which "updates" the site afterwards. The webparts are added by the second one.

sharepoint workflow

I am new this sharepoint development and i have task in hand to do the following.
1.When a new document added to the library, the system will prompt for approvers & audience from a database table. this will be stored for future revisions for the document.
2. Upon successful completion of assigning approvers, audience the system will initiate the workflow to complete the approval process.
It would be great if anyone can point the direction to do the following:
1.is it possible to call a aspx page/form from document library insert/update event?
2.How to assign approvers to a workflow programmatically?
Thanks in Advance!
Alex
I'm not sure it is possible to explicitly call another page but you can use the "Source" url parameter to specify the page they are directed to after they press OK. Obviously, you will have to change "www.google.com" to be your new URL.
/Lists/Announcements/NewForm.aspx?Source=www.google.com
You can probably do all of this using custom workflow. With custom workflow you have two options: creating the entire workflow in visual studio or create custom workflow actions and using SharePoint Designer to build the workflow.
Building custom Workflow Actions.

Sharepoint: Deploy Custom Lists and New Columns in lists

I've created a custom list & also added a column in the Announcement List. Question is, how can I include those newly created items when I create a fresh Web Application (like a script, feature or something)?
Additional Info: It's like when you're to deploy from your development machine to a staging or production server. I'd like to have a script or something to update my production server to have the new column i've added to the Announcement List. Just like SQL Server's ALTER TABLE command to update a SQL Server Table.
Is there an equivalent in Sharepoint Lists?
TIA!
Regarding the new custom list, this can be done using features. See How to: Create a Custom List Definition for more information. The Visual Studio Extensions for SharePoint (VS2005 / VS2008) will help you to extract the list definition if you've created it through the SharePoint UI. If you are fortunate enough to be using a custom site definition and don't have any webs created yet, you can set your site definition to create the custom list using feature stapling.
If you are attempting to apply these changes to webs that already exist, you can still use a feature to define your custom list. It will just appear as a type of list that can be created. Then to have the custom list automatically created for existing webs or to modify existing lists such as the Announcements list, you can use a feature receiver. This allows you to run any custom code when the feature is activated. See the MSDN article Feature Events for more information.
Alternatively, you could not use features at all as they can be difficult, time consuming and painful. In fact, this blog post has a good argument against the idea. You could try the tool mentioned on that page or other applications such as DocAve Content Manager and SharePoint Site Migration Manager.
Your question is not very clear but I think you may want to look at Application Templates.
Microsoft provide 40 pre-built templates in the link below and the same technology is available to you. Links from this page should lead you to information showing you how you can crate your own.
Application Templates for Windows SharePoint Services 3.0
http://technet.microsoft.com/en-us/windowsserver/sharepoint/bb407286.aspx

Resources