?
Solved

Pass Parent ID to Related List NewForm

Posted on 2012-04-09
1
Medium Priority
?
1,913 Views
Last Modified: 2012-04-12
I have a "parent" list and a "child" list.  The child list has a lookup to a column in the parent list. I've placed a Related Item View on the parent list DispForm.

When a user is viewing the DispForm, they can click Add New in the Related Item view, to add a new child item.  But the value of the parent item is not passed to the child NewForm.

Any suggestions on how to achieve this (I do have SPD).

Many thanks.
0
Comment
Question by:TEEDA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
dp_expert earned 2000 total points
ID: 37827400
Use javascript to get the ID from the URL and add to the URL of the "Add new item" link "?parentID=<id from url>".

Next use SPD to modify the newform.aspx. Use javascript  to read the parentID from url and then set the field to this value. Depending on the field you are using there will be different methods to achieve this - if you are using a single choice lookup field, then use this script (remember to input the ID of your field):

<script language="javascript" type="text/javascript">
parentID=window.location.href.split("parentID=")[1].split("&")[0];

_spBodyOnLoadFunctionNames.push("fillDefaultValues");

function fillDefaultValues(){
  var clInputId = "<ID of the INPUT FIELD>";//here input ID of the field
  value = parentID;

  var clInput = document.getElementById(clInputId);
  clInput.value = value;

  ShowDropdown(clInputId);

  var select=document.getElementById(clInput.opt);
  if (select != null){
   var opts = select.options;
   var l = opts.length;	
   for (var i=0; i < l; i++) {
      if (opts[i].text == value) {
        select.selectedIndex = i;
        break;
      }
   }
   OptLoseFocus(select);
  }
}</script>

Open in new window

0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question