Creating a Share. Point Parent/Child List Relationship–No SPD Version - So, over the years by far my most read blog posts are the ones detailing how to create Parent/Child list relationships in Share. Point and automatically populating the Parent (Lookup) ID of the Child list. Those posts being: You’d think at some point I’d stop kicking that dead horse, but no. Which brings me to this blog post. A couple of weeks ago I had an email from a gentlemen who wanted to create this Parent/Child list relationship, but his organization decided to not allow the use of Share. Point Designer (SPD). Hey, did you know it’s free? Well, my previous posts had always utilized SPD as an integral tool for creating these relationships. However, it’s very possible to create the same functionality using only Java. Script/j. Query. So, Why don’t we bring that leg back one more time and give that horse a smack while I show you how to create a Parent/Child list relationship in Share. Point 2. 01. 0 without using Share. Point Designer. Before we get started. Before we get started, make sure you are familiar with j. Query basics including deploying j. Query, linking scripts to Content Editor Web Parts, and setting Share. Point Form Fields. We will also be storing any scripts we write for this blog in that same document library. Also, make sure you have the lists that we’ll be using. By default, SharePoint Survey's "All Responses" view shows "View Response", "Created By", "Modified", "Completed" columns. There was a requirement to add one of the.
Just like every previous example we’ll be using the following list structure: Parent List: “Issue”Field Name. Field Type. All we need is default “Title” field for our needs Child List: “Time”Field Name. Field Type. Issue. IDLookup Field Type on ID field of “Issue” list. Hours. Numeric Field Type. You can also refer to my video from my earlier blog post on this topic for more step- by- step instructions on how to create these lists. In fact, I’ll just link the video for creating the lists here. For those of you comfortable with Share. Point and Java. Script/j. Query maybe this is all you need, for the rest I’ll go through the step- by- step “how” below. Edit the default Display Form for the Issue list a) Add Time list to the pageb) Set up web part connection between the Issue Display Form and the Time listc) Write a script that overwrites the “Add new item” link and passes in the Issue’s ID as a Query String parameter. Modify the default New Item Form for the Time list and add a script that: a) Sets the value of the Issue. ID lookup fieldb) hides the “Issue ID” field to stop meddling users and their darn dogs from changing it. That’s all there is to it. Not too hairy I hope? Then we are going to add a Web Part Connection between the Issue Display Form Web Part and the Time list Web Part using the “ID” from the Issue list and the “Issue. ID” from the Time list as filter members. After this is complete, you will see a list of all associated Time entries for an Issue whenever you view an issue. Edit Default Display Form for Issue, Add Time List, Create Web Part Connection to Filter Time. The next step is to write a script that will overwrite the “Add new item” link of the Time list so that we can call the Share. Point “New. Item. Time entry as well as pass the parent Issue’s ID to the New Item form as a Query String variable. The following script will be used to accomplish this task. You can use relative URL to the web application or the FQDN. Element). attr(! Not as I do! Now that we have our script written and uploaded to our Site. Assets document library, let’s add it to the Issue Display form. Insert Display. Issue. Issue Display Form. Okay, so at this point we have modified our Issue Display form so that it only shows Time entries associated with the current issue and we’ve added a script that allows us to pass in the ID of the Issue to the Time New Item Form as the Query String parameter “Issue. ID”. Yes, I know you can’t “see” it because of the modal window, but trust me, it’s there. Have I ever knowingly lied to you before? The next thing we need is a script that can read the “Issue. ID” Query String parameter value, and then store that value in the “Issue. ID” Lookup field on the New Time form. The Script below does just that. There are a couple of things I would like to point out about the script before you go pasting it into your solutions: 1) Again, you REALLY should create a utility library for “get. Paramter. By. Name”. I toyed with doing that for you in this blog post, but I really wanted to keep it simple as I know many of you don’t want to be bogged down with the extra details. Share. Point has a “feature” with lookup fields in IE where if you have more than 2. I actually blogged about that if you want to know more at: Setting Share. Point Lookup Lists w/ j. Query (+/- 2. 0 items). I bring this up because I have to take this into account when setting and hiding the Issue. ID in the script below. You’ll see what I mean. Again, unless I broke something the script is going to read the Query String parameter “Issue. ID” and set the value of the “Issue. ID” lookup field to the corresponding value. The script will then hide the Issue. ID field from the New Time form completing our magical journey into the world of Share. Point for this evening. Insert New. Time. Time New Item Form. Tada. And in Conclusion. There you go, setting up a Parent/Child list relationship in Share. Point 2. 01. 0 without using SPD. I think I may actually like this method best from a maintenance standpoint. Have a better idea on how to accomplish this? Please share with the rest of the class, the comments section isn’t there for spammers to hock their wares? If you’re lucky you will not have to endure another one of these posts from me until v. Next. As always, please let me know if I was not clear about something and I’ll see what I can do to explain myself better. One last note, You can build upon this example and pass multiple values from the Parent Display form in the Query String and set multiple fields in the Child’s New Item form, just modify the script to pass more values in the “New. Item. 2” function, and modify the other script to set more fields. Refer to my previously mentioned blog post A Dummies Guide to Share. Point and j. Query–Getting & Setting Share. Point Form Fields for more information on how you might read and set Share. Point form field values. Thanks again for stopping by, I hope maybe you learned a trick or two.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
August 2017
Categories |