hi all, i m new to sharepoint so a silly quetion.

11 views
Skip to first unread message

vicky

unread,
Aug 25, 2010, 1:37:13 AM8/25/10
to Dev SharePoint
i have been given a work to make a event handler. the scenario is:

-> put an item from one list to another. (For e.g. take any four
columns that constitute an item.) (deployable as WSP)
1. There would be 2 lists (Primary & Slave)

2. When a new item would be created in Primary list, it
would be replicated in Slave List.

3. If an item is updated in the Primary list it would be
updated in the Slave list as well.


now the problem is that i cant deploy it as a feature. so what will be
the best way to deploy it.
also can somebody verufy my code for itemadded method not working:
class EventHandlerClass : Microsoft.SharePoint.SPItemEventReceiver
{
SPSite objSite;
SPWeb objWeb;
SPList objList1,objList2;

void SimpleEventHandle()
{
}
public override void ItemAdded(SPItemEventProperties
properties)
{
objList1 = objWeb.Lists["simple list"];
objList2 = objWeb.Lists["simple list copy"];
SPListItem updatedItem = properties.ListItem;
SPListItem copyItem = objList2.Items.Add();
copyItem["Title"] = updatedItem["Title"];
copyItem["Fname"] = updatedItem["Fname"];
copyItem["Lname"] = updatedItem["Lname"];
copyItem.Update();
}

}

Symon

unread,
Aug 26, 2010, 11:17:19 PM8/26/10
to Dev SharePoint
Hi Viki,

I would probably do this using SPD Workflow and the OOB workflow
actions provided to prevent having to deploy as a feature or solution,
as it seems to be achievable using existing functionality. Using OOB
SPD Workflow Designer, this will work only if the primary and
secondary lists are on the same SharePoint site. Custom Event
handlers associated with th elist, or a VS workflow would need to be
developed if the lists are not on the same site. Alternatively, you
could install the free workflow Extension Package from CodePlex:
http://spdwfextensions.codeplex.com/

To configure using SharePoint Design OOB Workflow Actions:

1. Primary list has lookup column which is set to to the corresponding
item in the secondary list.
2. Workflows associated with Primary list (On Create, On Change) are
triggered when an item is added / updated
A -- Workfllow copies item to secondary list if new (update
lookup field calue in primary list item)
or B -- Workflow Updates the corresponding item in the secondary
list if updated.

Configuring this as two simple workflows, one to handle new items and
one to handle updated items should allow you to develop in a short
space of time. Let me know if this doesn't help, and I can give you a
hand with the Event Handler, but haven't written one for a few months
now so will probably have to brush up a little. Are you using WSS,
MOSS 2007 or SharePoint 2010?

Symon
Reply all
Reply to author
Forward
0 new messages