Creating a sharepoint parent child list relationship 1 6

Parent-Child relationship between two lists in SharePoint – Part 1 |

creating a sharepoint parent child list relationship 1 6

Creating a SharePoint List Parent / Child Relationship - Out of the Box nameVal[1] =' '); vals[nameVal[0]] = nameVal[1]; } var issueID = vals["ID "]; //use this to bring Posted on Thursday, December 16, PM | Back to top. You can create Lookup columns in your child list adding the required columns from the Parent list. 1. Go to Child List > List Settings > Create Column. 2. 6. Click on OK, now you'll see all the selected columns will be added to your child list. Representing parent-child relationships in SharePoint lists · 1. One of these was creating a Parent / Child relationship between lists so 1. Open up the “Common Data View Tasks” for Time List. 2. Select “Create a new parameter ” for Value. 6. Give the parameter a Name of “IssueID”.

Getting Started You will need a SharePoint website where you have basic list and page editing permissions. If you want to just follow along with this example, you can do this in your My Sites content personal site collection if this has been enabled for you. You will need a document library or some other location on the network where you can store a JQuery text file.

The permissions level and visibility of this library should be the same as the parent-child lists you will be exposing. An easy way to accomplish this is to put the library for your script in the same site or site collection as the parent-child lists. However, if your scenario is more complex, you might consider using a centrally stored JQuery script file that can be referenced from various sites around your farm. If you just want to follow along with this example, you may simply create a document library in the site where you are working, or use a document library you already have.

You will need to download a JQuery text file and place it in the aforementioned document library. Later you will embed a link to this script in some JavaScript code you will put in your list forms. The example below uses JQuery version 1. Chances are the code here will work with later versions as well, but if you have trouble getting a newer version to work, try going back to this version. You will need to create your parent and child lists.

Our contrived example will use an out-of-the-box Contacts list called ParentContacts and an out-of-the-box Tasks list called ChildTasks. Later we will make a small customization to the ChildTasks list.

I used the Blank Site template to create the site. At this point, I have not made any customizations, only laid the foundation. The basic foundation for the example, with document library, parent list, and child list First Customization: Lookup Field on the Child List Something that takes a little while to get used to is which side of a parent-child relationship in SharePoint we actually modify in order to define the relationship.

The answer is that it is the child list that we modify. The parent list does not include explicit fields or settings to define the relationship. The child defines the relationship. Navigate to the ChildTasks list and look for the List Settings button on the ribbon. It is on the far right end of the List tab. On the List Settings page, look for the Columns area. The image below Figure 2 shows the default columns list for our out-of-the-box Tasks list called ChildTasks.

The default Columns list for the ChildTasks list, before we have added the Lookup column In our example, we are going to click on the Create column link, but you could also choose a site column you have defined instead. Creating the column on the list directly keeps it isolated to just this list.

The image below Figure 3 shows the first section of the form to define a new column, Name and Type. Values for the Name and Type section of the form The image below Figure 4 shows the second section of the form, Additional Column Settings. Some things to note from this form: We are requiring a value, meaning a child Task must have a parent Contact.

We are not requiring unique values, since we want a parent Contact to be able to own multiple child Tasks. We have chosen the ParentContacts list as the source of our Lookup value. We are using the Full Name field from the parent list, which just happens to be the best value from a Contact list to show in a dropdown list on the child form. The field you choose here should be one that will help a human operator distinguish one parent in the list from another using a single value.

These are generally convenient to leave on. Values for the Additional Column Settings section of the form The image below Figure 5 shows the final portion of the form, Relationship.

In our example, we have chosen to enable relationship enforcement, which is kind of like foreign key referential integrity in a database.

We have chosen to enable the Cascade delete option, which means that if a parent Contact is deleted, all of its child Tasks will be automatically deleted. Values for the Relationship section of the form The image below Figure 6 shows the confirmation dialog you see if you decide to enable relationship enforcement. Confirmation dialog to create an indexed column, which is needed for enforcing the Lookup relationship Figure 7 below shows the result of our work: New ParentContact column has been added to the ChildTasks list At this point, we need to pause and create some test data.

Specifically, we need a couple parent Contacts before we get into the customizations that allow us to start adding child Tasks. It is useful to define at least two or three parent items so that later you can reliably test the parent pre-selection on the child New Item form.

Figure 8 shows that we have defined two test items in the ParentContacts list. We have added some test data to the ParentContacts list Switching back to the ChildTasks list, we can perform a quick test to verify that our Lookup column relationship is reflected in the ChildTasks list. The New Item form of the ChildTasks list, showing the ParentContact dropdown from our Lookup field This is one of three forms that SharePoint automatically generates for us when we define a new list.

However, so far we are just looking at the default form. Notice the ParentContact dropdown list at the bottom of the form, showing the Full Name field of the ParentContacts list. SharePoint automatically added this dropdown to the form based on the list settings we defined above. Right now, using this default form, we can type in the details for a new ChildTask, use this dropdown list to choose a ParentContact, and save the new ChildTask.

However, this dropdown is only part of what we need. Returning to the big picture, at this point we have three remaining gapsin our solution: Right now the only way we have to add new ChildTasks is to navigate separately to the ChildTasks list.

We have a usability and data integrity problem: Notice in Figure 9 that the first ParentContact in the list is automatically chosen, which is a default behavior of SharePoint.

We have solutions to these challenges. Keep reading… Second Customization: As we mentioned, SharePoint automatically creates three forms when we define a new list. But I havent figured it out yet Any idea how to grab and use that in a dataview on the same page? Left by Adrian M Harris on Jan 12, 6: I'll play with it and see what I come up with.

Left by Mark on Jan 13, Please let me know if you find anything. Left by Adrian M Harris on Jan 13, 4: Can you think of any ways to do this continuing from this approach or other approaches without custom code?

Left by Alex Talarico on Jan 15, 3: Can you give me a couple of real world examples and I'll see what I can come up with? Left by Mark on Jan 16, I believe you missed one step before you update the link to create a new time log entry Go to the Editing tab of the Data View Properties and make sure to check off the "show insert item link" option Note: If anyone is still having problems, please let me know.

Left by Mark on Feb 20, 8: The value needs to come from the parent list item. How do I go about creating the parameter so that it is available in the newform. I have added a second call to setValueForFieldName with the appropriate new field name specified. The problem is that the querystring does not contain a value for the second parameter I have set up.

My href tag looks like this in the dispform. The full name never appears in the link for adding a new child list item. How do I create the parameter so that it gets its value from the parent list item and is passed as a query string parameter to the newform. Left by Phase Dave on Feb 22, 3: Then, using the ParentID on your child list just do the "set field in current item" action in the Workflow to set any additional fields in your child list with data from your parent list.

Creating a SharePoint List Parent / Child Relationship - Out of the Box

Hope this helps, Left by Mark on Feb 22, 5: I was going to use an update workflow anyways in the event that relevant parent data fields changed, I would need to update the child list item fields. Why is the parent list item ID so easy to retrieve but not the rest of the fields in the parent list? If you have time, I would love to learn how to do this Left by Phase Dave on Feb 22, 5: Using Sharepoint Designer, I created a new workflow attached to the child list and runs when the child list item is created.

In step 1, I add a single action "Set field in current item". I set the update field to the appropriate child field to be updated. When I try to set the "value to" field, I am confused. I change the source to the parent table and select the appropriate field. In the "Find the list item" section, I select the parent list ID field. When I attempt to set the "value" in the "Find the list item" section, I don't have the choice to select the child list item field.

If I filter the value fields by "current item", the appropriate child list column is not available to select.

creating a sharepoint parent child list relationship 1 6

If I select the child table instead of "current item", I am prompted to specify which specific child list item to get the value from. It is like I am in an endless loop of narrowing down my selection of matching the child to the parent.

This will also necessitate a change in the javascript to populate a list field instead of a text field. I'll give you the details tomorrow and update the blog. Sorry about the confusion. Left by Mark on Feb 22, 7: I created a calculated field in the parent list called IDNum that is of type "Number" and is automatically assigned the value of the List ID.

So for adding a new child list item, everything is working properly. Now for updating the child list items when the parent list item changes, I am having problems. My idea for updating the child list items when the parent changes does not work because of the 1 to many relationship.

It only updates one of the child list items. Any ideas for updating all of the child list items when the parent list item changes? Left by Phase Dave on Feb 22, 7: You should be able to set this field on the creation of your Parent Item with a workflow. THEN connect to this new field in your workflow when the child list item is created.

creating a sharepoint parent child list relationship 1 6

It's a hack, but it will work with the number field you have. I hope I'm not getting too confusing now. You will need to create a custom workflow to do this.