1

I have got two lists with diffrent number of column:

First List have got:

Column "A", Column "B" and "Status" field with Choice: active, and non active.

Secaund list have got this kind of column:

Column "A", Column "B", Column "C", Column "D", Column "E", and "Status" field with Choice: active, and non active

How to synchronize this list together. By powershell, or workflow?

Have You know any solution ?

OneList will have different permission then Secound list.

If something chainging on column A or B or Status, in first list is changing in secaund list, and if change in Secound is change in first list.

This list could synchronization together and always by synchronize. have You got any sample of code ?

1

My suggestion is using Event Receiver in two list with code behind in the ItemAdded and ItemUpdated funtion. The below is the concept of ItemUpdated, this will update A column's value of item which has same ID in sync list.

 public override void ItemUpdated(SPItemEventProperties properties)
{
    base.ItemAdded(properties);
    using (SPSite site = new SPSite(properties.WebUrl))
    {
       using (SPWeb web = site.OpenWeb())
       {
          web.AllowUnsafeUpdates = true;
          SPListItem item = properties.AfterProperties;
          var aValue= item["A"].ToString();

          SPList syncList = web.Lists["SecondList"];
          SPListItem syncItem = syncList.GetItemById(properties.ListItemId)
          syncItem["A"] = aValue;
          syncItem.Update();
        }
    }
}
  • Thanks for that. And first list ? – Grzegorz Z May 21 '15 at 12:34
  • I think we will have 4 event receiver. ItemUpdated and ItemAdded in both lists you want to synchronize. And one thing, you'll need to stop EventReceiver before updating or adding for prevent the loop by using : this.EventFiringEnabled =false. – trantab May 21 '15 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.