Solved

Pass Parent ID to Related List NewForm

Posted on 2012-04-09
1
1,856 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

690 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