3

In SharePoint 2013, i am designing relational lists which will be displayed in one single form. For example, I have 4 lists;

  • List A
  • List B
  • List C
  • List D

For every record that is created in List A, I would like to write about 20 records of related information in List B, List C and List D. What is the best way to perform CRUD operations in this case? Kindly suggest.

Note: I also have lookup information in other 4 lists which are just used for lookup and display.

Edit: I forgot to mention that I can use only JSOM and environment is Office 365

3

You need to create an event reciever which handles ItemAdded event. Refer to this MSDN article on how to create one.

Evey time an item is added to list A, you will be able to programmatically add items to other lists and do other operations as well.

For an Office 365 solution check Remote Event Receivers here.

  • I forgot to mention that I can use only JSOM and environment is Office 365 – Still Learning Feb 16 '16 at 14:11
  • Can you deploy a CSOM Remote Event Receiver? Updated my answer. – Paul Strupeikis Feb 16 '16 at 14:26
  • Nope, I can only use JSOM as of now – Still Learning Feb 17 '16 at 10:14
1

Yes, you can achieve this using "ItemAdded" event receiver.

NOTE: If event receiver is scoped to "Site" then it will fired for all lists. So to run the event receiver on specific list only then, you must ensure that your event receiver scoped to "Web".

However we can also force Site Scoped event receiver to work for specific list by checking the List Name. Following code will help you.

public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);
            properties.Web.AllowUnsafeUpdates = true;
            try
            {
                if (properties.ListTitle.Equals("List-A"))
                {
                 //Get current item values as below.
                 string name=properties.ListItem["Name"].ToString();
                 //Get your lists (List-B,C..) here and update the field you want.
                }

            }
            catch (Exception)
            {
            }
            finally
            {
                properties.Web.AllowUnsafeUpdates = false;
            }

        }

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.