Page 1 of 1

Cascading Drop-Down Without Forms Designer

Posted: 04 May 2017
by kkreitzer
Hello,

We have a standard SharePoint EditForm.aspx that we need to have a cascading drop down on. The "Dependents" field should only show items that are related to the field "Employee". I am not familiar enough with JS to figure this out. Below is what I have so far, but I am receiving error messages in the developer console.

function (term, page) {

//Get LookupField value
var employeeValue = new item.get_item('Employee');
var emplID = employeeValue.get_lookupId();

if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby=Created desc&$top=10&$filter=Employee/ID eq '" + emplID + "'";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField}&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "')&$top=10&$filter=Employee/ID eq '" + emplID + "'";
}