jeudi 12 mars 2015

How to make a dropdown field in a NewForm.aspx to point to its parent list



I currently replaced someone in a existing SharePoint project and I'm having trouble understanding the previous person's work. I will try to explain the setup and explain my question after to make things clear.


We have a list called Class Sessions in the format of a calendar, it contains scheduled classes with their respective dates, instructors, titles and other information. We also have a Enrollment list that that takes care of enrolling students to the Class Session list. So from the Class Session's DispForm.aspx page we can prompt Enrollment's NewForm.aspx page.


Class Session's DispForm snippet showing link to Enrollment's NewForm


Class Session DispForm


Here is Enrollments NewForm


Enrollment's NewForm


The ClassSession used to point to the correct dropdown class session a week ago (to F101 - Admin 101 (3/8/2015)), but now it always defaults to F101 - Admin 101 (1/16/2015). I never changed any aspx file and dont know what caused this function to stop working. Here is the code of interest for Enrolment's NewForm.aspx



<Content xmlns="http://ift.tt/UWTV9g"><![CDATA[<script src="http://ift.tt/1rJStC0" type="text/javascript"></script><script type="text/javascript">
function registerNewStudent(event)
{
NewItem2(event, "/sites/FCU/TrainingManagement/Lists/Students/NewForm.aspx");
}
$(document).ready(function()
{
var classSessionField = "select[title='"+ "Class Session Required Field" +"']";
var args = location.search.slice(1, location.search.length).split("&");
for (var i in args)
{
var nameVal = args[i].split("=");
if(nameVal[0] == "ParentID")
{
$(classSessionField).val(nameVal[1]);
$(classSessionField).parent().parent().parent().hide();
}
}
});


What the previous person did here used to work to automatically set the ClassSession dropdown to the parents corresponding class session. But now it just stop working and I have no clue why. I dont understand the javascript enough to debug the problem and really need some help here. I know I made changes to the Current Sessions and Enrollment lists, like change column names and stuff.


I took a look at this guide but could not understand my NewForm.aspx based on the information on the guide.


Anyhelp with my problem would be greatly appreciated.


Thank you!








0 commentaires:

Enregistrer un commentaire