开发者

Automatically copy data from SP2010 external list to an SP2010 custom list

开发者 https://www.devze.com 2023-02-27 05:03 出处:网络
I have an SP 2010 开发者_Python百科external list that is populated with customer names. The list is updated occasionally throughout the day. I would like to automatically copy the newly added names to

I have an SP 2010 开发者_Python百科external list that is populated with customer names. The list is updated occasionally throughout the day. I would like to automatically copy the newly added names to another SP 2010 list when it is updated or at a set time (hourly).

Is there an easy way to do this? And if not, is there at least a way to do it?

Thank you for your help.


Unfortunately, External Lists do not support workflows. So workflow is not a solution here.

One of the way to do this would be to create a custom timer job to synchronize items & configure to run it periodically. See details about how to create & register custom job here.

But this approach has it's own drawbacks:

  1. it is complex enough
  2. you will need a farm scoped feature + receiver to register the job. The reason is that for security purposes you can't register a custom job from within the code running in Content Web application (so it will not work in site collection level feature receiver), only from code running in Central Admin app.


I'd build a windows service or a timed job in SharePoint and then hook up a compatible ado.net connector to my process. This way you can copy or synchronize data between your two lists as if they where ordinary SQL tables.

private void example()
{    
    // Fetch data from your left sharepoint
    SharePointConnection leftConnection = new SharePointConnection(@"
        Server=mysharepointserver.com;
        Database=mysite/subsite
        User=spuser;
        Password=******;
        Authentication=Ntlm;
        TimeOut=10;
        StrictMode=True;
        RecursiveMode=RecursiveAll;
        DefaultLimit=1000;
        CacheTimeout=5");

    leftConnection.Open();

    string leftQuery = "SELECT * FROM LeftList";
    SharePointDataAdapter adapter = new SharePointDataAdapter(leftQuery, leftConnection);

    DataTable dt = new DataTable();
    adapter.Fill(dt);


    // Insert data in right sharepoint
    SharePointConnection rightConnection = new SharePointConnection(@"
        Server=anothersharepointserver.com;
        Database=whateversite
        User=spuser;
        Password=******;
        Authentication=Ntlm;
        TimeOut=10;
        StrictMode=True;
        RecursiveMode=RecursiveAll;
        DefaultLimit=1000;
        CacheTimeout=5");

    rightConnection.Open();

    // build your rightQuery here
    string rightQuery = "Insert into"...

    SharePointCommand command = new SharePointCommand(rightQuery, rightConnection);
    command.ExecuteNonQuery();

}

You could try this one http://www.bendsoft.com/net-sharepoint-connector/. This ado.net connector uses the API of SharePoint so you can run the service in a third machine and as long as it has access you'll be fine.

There are some examples and howto's at http://blog.bendsoft.com


A workflow can be created for this easily. The workflow can be triggered when an item is newly created or updated. The workflow can create the same item into another list.

Try creating the workflow using SharePoint designer, which is quiet straight forward.

Hope this helps. :)


Why do you want to copy the external data to another list? What is the purpose of doing this? Perhaps there is a better solution for what you are trying to do.

The reason I say this, is because you are going to be replicating data and could get a bit tricky, especially if you allow the data to be updated in both places.


I'd use MS access in order to copy data out of one table, and push it into another table. I've used Access/Sharepoint extensively, and it's a little bit buggy.. but it generally works. It might crash- but for 90% of small tables, heck yes you can do this!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号