Strange issue with SPCascadeDropdowns

Jun 29, 2012 at 2:14 PM

Hi

I am using the following code to create a cascading dropdown and then prepopulate fields on a form. 

	$().SPServices.SPCascadeDropdowns({
		relationshipList: "Heatmap Skill Codes",
		relationshipListParentColumn: "Domain",
		relationshipListChildColumn: "Title",
		parentColumn: "ALP Domain",
		childColumn: "ALP",
		simpleChild: true,
		debug: true
	});


	$("input[title='Applicant Name']").val(firstName + " " + lastName);
	$("input[title='Applicant EIN']").val(userName);
	$("input[title='Applicant OUC']").val(department);
	$("input[title='Proposed Start Date']").val(startDate);
	$("input[title='Proposed End Date']").val(endDate);
	$("input[title='Applicant Email']").val(email);
alert(alpTitle);
	$("input[title='ALP Domain']").val(alpTitle);

The cascade is working fine as are most of the propopulating lines afterwords, but when it comes to setting the value of the ALP Domain field, I cannot get it to work at all.

I have tried $("input[title='ALP Domain']).val(alpTitle);  

Also have tried $("select[title='ALP Domain]).val(alpTitle);

I am beginning to suspect that SPCascadeDropdowns is stopping me from inserting the value to the field. Could this be the case ?  Oh and the ALP Domain contains less than 20 items by the way.

Thanks

Ben

Jun 29, 2012 at 3:49 PM

This is driving me even more mad now - I have changed the code as follows .....

$().SPServices.SPCascadeDropdowns({
	relationshipList: "Heatmap Skill Codes",
	relationshipListParentColumn: "Domain",
	relationshipListChildColumn: "Title",
	parentColumn: "ALP Domain",
	childColumn: "ALP",
	simpleChild: true,
	debug: true
});

$("input[title='Applicant Name']").val(firstName + " " + lastName);
$("input[title='Applicant EIN']").val(userName);
$("input[title='Applicant OUC']").val(department);
$("input[title='Proposed Start Date']").val(startDate);
$("input[title='Proposed End Date']").val(endDate);
$("input[title='Applicant Email']").val(email);
alert(alpTitle);
//setLookupFromFieldName("ALP Domain", alpTitle);
var theInput = getTagFromIdentifierAndTitle("select","","ALP Domain");
if(theInput != null) {
	theInput.value = alpTitle;
}

The new bit at the end at least has an effect as it now blanks the drop-down. However the intended value has gone completely missing.

I am obviously doing something terribly wrong here.

Ben

Coordinator
Jun 29, 2012 at 5:59 PM

Ben:

You should get into the habit of looking at the rendered control for the field so that you can determine how to set it. The ALP Domain column is a dropdown, which makes it a select if it has fewer than 20 values. You need to see what the values are for that select - hint: it'll be the ID of the lookup value, not the text.

Be careful here, though. If the column ever has 20+ values, it won't be a simple dropdown anymore and your script will break.

M.

Jul 2, 2012 at 12:30 PM

Hi Marc

I think you are right - I need to get into some good habits with this type of thing.

Thank you for your help - I have the code doing what it should now.

Cheers

Ben