Skip to main content
Post Undeleted by Dikesh Gandhi
Post Deleted by Dikesh Gandhi
added 8 characters in body
Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58

Put this below code in List A event receiver. This method will copy only current item to List B that you add in the List A.

Code:

public override void ItemAdded(SPItemEventProperties properties)
{
    base.ItemAdded(properties);

    using (SPSite site = new SPSite("http://MyWeb/sites/mysite/"))
    {
        using (SPWeb web = site.OpenWeb())
        {                
            SPList desList = web.Lists.TryGetList("B");
            if (desList != null)
            {
                SPListItem desItem = desList.Items.Add();
                foreach (SPField field in properties.itemListItem.Fields)
                {
                    if (!field.ReadOnlyField && !field.Hidden && field.InternalName != "Attachments")
                    {
                        if (desItem.Fields.ContainsField(field.InternalName))
                        {
                            desItem[field.InternalName] = properties.item[fieldListItem[field.InternalName];

                        }

                    }
                }
                desItem.Update();
            }
        }
    }

}

This method will copy the list item from List A to List B after you add list item to List A.

Hope this will help you!

Put this below code in List A event receiver. This method will copy only current item to List B that you add in the List A.

Code:

public override void ItemAdded(SPItemEventProperties properties)
{
    base.ItemAdded(properties);

    using (SPSite site = new SPSite("http://MyWeb/sites/mysite/"))
    {
        using (SPWeb web = site.OpenWeb())
        {                
            SPList desList = web.Lists.TryGetList("B");
            if (desList != null)
            {
                SPListItem desItem = desList.Items.Add();
                foreach (SPField field in properties.item.Fields)
                {
                    if (!field.ReadOnlyField && !field.Hidden && field.InternalName != "Attachments")
                    {
                        if (desItem.Fields.ContainsField(field.InternalName))
                        {
                            desItem[field.InternalName] = properties.item[field.InternalName];

                        }

                    }
                }
                desItem.Update();
            }
        }
    }

}

This method will copy the list item from List A to List B after you add list item to List A.

Hope this will help you!

Put this below code in List A event receiver. This method will copy only current item to List B that you add in the List A.

Code:

public override void ItemAdded(SPItemEventProperties properties)
{
    base.ItemAdded(properties);

    using (SPSite site = new SPSite("http://MyWeb/sites/mysite/"))
    {
        using (SPWeb web = site.OpenWeb())
        {                
            SPList desList = web.Lists.TryGetList("B");
            if (desList != null)
            {
                SPListItem desItem = desList.Items.Add();
                foreach (SPField field in properties.ListItem.Fields)
                {
                    if (!field.ReadOnlyField && !field.Hidden && field.InternalName != "Attachments")
                    {
                        if (desItem.Fields.ContainsField(field.InternalName))
                        {
                            desItem[field.InternalName] = properties.ListItem[field.InternalName];

                        }

                    }
                }
                desItem.Update();
            }
        }
    }

}

This method will copy the list item from List A to List B after you add list item to List A.

Hope this will help you!

deleted 111 characters in body
Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58

Put this below code in List A event receiver. This method will copy only current item to List B that you add in the List A.

Code:

public override void ItemAdded(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);

        using (SPSite site = new SPSite("http://MyWeb/sites/mysite/"))
        {
            using (SPWeb web = site.OpenWeb())
            {                
                SPList desList = web.Lists.TryGetList("B");
                if (desList != null)
                {
                    SPListItem desItem = desList.Items.Add();
                    foreach (SPField field in properties.item.Fields)
                    {
                        if (!field.ReadOnlyField && !field.Hidden && field.InternalName != "Attachments")
                        {
                            if (desItem.Fields.ContainsField(field.InternalName))
                            {
                                desItem[field.InternalName] = sourceItem[fieldproperties.item[field.InternalName];

                            }

                        }
                    }
                    desItem.Update();
                }
            }
        }

    }

This method will copy the list item from List A to List B after you add list item to List A.

Hope this will help you!

Put this below code in List A event receiver. This method will copy only current item to List B that you add in the List A.

Code:

public override void ItemAdded(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);

        using (SPSite site = new SPSite("http://MyWeb/sites/mysite/"))
        {
            using (SPWeb web = site.OpenWeb())
            {                
                SPList desList = web.Lists.TryGetList("B");
                if (desList != null)
                {
                    SPListItem desItem = desList.Items.Add();
                    foreach (SPField field in properties.item.Fields)
                    {
                        if (!field.ReadOnlyField && !field.Hidden && field.InternalName != "Attachments")
                        {
                            if (desItem.Fields.ContainsField(field.InternalName))
                            {
                                desItem[field.InternalName] = sourceItem[field.InternalName];

                            }

                        }
                    }
                    desItem.Update();
                }
            }
        }

    }

This method will copy the list item from List A to List B after you add list item to List A.

Hope this will help you!

Put this below code in List A event receiver. This method will copy only current item to List B that you add in the List A.

Code:

public override void ItemAdded(SPItemEventProperties properties)
{
    base.ItemAdded(properties);

    using (SPSite site = new SPSite("http://MyWeb/sites/mysite/"))
    {
        using (SPWeb web = site.OpenWeb())
        {                
            SPList desList = web.Lists.TryGetList("B");
            if (desList != null)
            {
                SPListItem desItem = desList.Items.Add();
                foreach (SPField field in properties.item.Fields)
                {
                    if (!field.ReadOnlyField && !field.Hidden && field.InternalName != "Attachments")
                    {
                        if (desItem.Fields.ContainsField(field.InternalName))
                        {
                            desItem[field.InternalName] = properties.item[field.InternalName];

                        }

                    }
                }
                desItem.Update();
            }
        }
    }

}

This method will copy the list item from List A to List B after you add list item to List A.

Hope this will help you!

added 79 characters in body
Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58

Put this below code in List A event receiver. This method will copy only current item to List B that you add in the List A.

Code:

public override void ItemAdded(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);

        using (SPSite site = new SPSite("http://MyWeb/sites/mysite/"))
        {
            using (SPWeb web = site.OpenWeb())
            {                
                SPList desList = web.Lists.TryGetList("B");
                if (desList != null)
                {
                    SPListItem desItem = desList.Items.Add();
                    foreach (SPField field in properties.item.Fields)
                    {
                        if (!field.ReadOnlyField && !field.Hidden && field.InternalName != "Attachments")
                        {
                            if (desItem.Fields.ContainsField(field.InternalName))
                            {
                                desItem[field.InternalName] = sourceItem[field.InternalName];

                            }

                        }
                    }
                    desItem.Update();
                }
            }
        }

    }

This method will copy the list item from List A to List B after you add list item to List A.

Hope this will help you!

Put this below code in List A event receiver

Code:

public override void ItemAdded(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);

        using (SPSite site = new SPSite("http://MyWeb/sites/mysite/"))
        {
            using (SPWeb web = site.OpenWeb())
            {                
                SPList desList = web.Lists.TryGetList("B");
                if (desList != null)
                {
                    SPListItem desItem = desList.Items.Add();
                    foreach (SPField field in properties.item.Fields)
                    {
                        if (!field.ReadOnlyField && !field.Hidden && field.InternalName != "Attachments")
                        {
                            if (desItem.Fields.ContainsField(field.InternalName))
                            {
                                desItem[field.InternalName] = sourceItem[field.InternalName];

                            }

                        }
                    }
                    desItem.Update();
                }
            }
        }

    }

This method will copy the list item from List A to List B after you add list item to List A.

Hope this will help you!

Put this below code in List A event receiver. This method will copy only current item to List B that you add in the List A.

Code:

public override void ItemAdded(SPItemEventProperties properties)
    {
        base.ItemAdded(properties);

        using (SPSite site = new SPSite("http://MyWeb/sites/mysite/"))
        {
            using (SPWeb web = site.OpenWeb())
            {                
                SPList desList = web.Lists.TryGetList("B");
                if (desList != null)
                {
                    SPListItem desItem = desList.Items.Add();
                    foreach (SPField field in properties.item.Fields)
                    {
                        if (!field.ReadOnlyField && !field.Hidden && field.InternalName != "Attachments")
                        {
                            if (desItem.Fields.ContainsField(field.InternalName))
                            {
                                desItem[field.InternalName] = sourceItem[field.InternalName];

                            }

                        }
                    }
                    desItem.Update();
                }
            }
        }

    }

This method will copy the list item from List A to List B after you add list item to List A.

Hope this will help you!

Source Link
Dikesh Gandhi
  • 7.2k
  • 4
  • 31
  • 58
Loading