Question

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://schemas.microsoft.com/WebPart/v2/ContentEditor"><![CDATA[<script src="https://code.jquery.com/jquery-1.11.1.min.js" 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!

Was it helpful?

Solution

The problem in this situation was that I changed the column name Class Session to ClassSession in the Enrollment list. Therfore, the input control's title for the ClassSession field changed. So things went bad becasuse the variable ClassSessionField in the NewForm file was hardcoded to "select[title='"+ "Class Session Required Field" +"']"; instead of "select[title='"+ "ClassSession Required Field" +"']";.

If you ever want to make sure what the actual title is just get FireFox's Firebug add-on and inspect any field on your browser. It should show the title field.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top