0

I am using SP2013 on premise. I have 3 lists:

  1. Projects
  2. Requirements
  3. Issues.

Lists 2 & 3 have been added to List 1 DispForm.aspx and a lookup column and query string filter links them so that when a Project is selected a lookup column ID connects/selects only corresponding Requirements and Issues all on the same page.

Problem is that when I select the New Item link for Lists 2 or 3 on said page the ID is not included in the url and therefore I cannot do a query string on to pre-fill the Project ID Lookup value. So I need to some how append part of the current page url ".../Lists/Project%20Details/DispForm.aspx?ID=1" (without the &source) and append to the current DispForm.aspx (without the &Rootfolder) as the &Source=".../Lists/Project%20Details/DispForm.aspx?ID=1" but can't be hardcoded, has to be able to query the ID variable from the current URL.

Any suggestions or ideas? I had a solution if I used a Document Set as the Project list but Document Sets proved to be unworkable in other areas so I am using 3 regular lists instead.

1 Answer 1

0

So I realize now that the full URL that SP was generating upon clicking the New Item link was the problem as it did not include the ID and so on the default Disp.aspx page of List 1 the URL just needs to be truncated to exclude everything after ID=1. Here is the code that I used:

var newURL = location.href.split("&")[0]; window.history.pushState('object', document.title, newURL);

Now once the actual NewForm.aspx loads I can now query the URL for the ID and populate the lookup column using this code:

setTimeout(function(){ var theValue = GetUrlKeyValue("ID",false,unescape(GetUrlKeyValue("Source"))); document.getElementById("Project_x0020_Name_c9c83d51-e59d-4fc8-b811-d8eee5fd6818_$LookupField").value = theValue; },1000);

Everything is connected now and works as required. Hope this helps someone else solve similar configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.