[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Pass Parent ID to Related List NewForm

Posted on 2012-04-09
1
Medium Priority
?
1,978 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

649 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