SPFilterDropdown - Retain Inactive Value in Edit

Oct 28, 2013 at 3:41 PM
I'm using SPFilterDropdown to filter personnel based on an Inactive/Active status. I was able to get it to work, but noticed that if I have a person selected that was once Active, but is now Inactive, and I edit the form, the value turns to blank, since it's not Active anymore. Is there a way to retain the person selected even if they are Inactive? For archiving purposes, I want to be able to retain this person.
Coordinator
Oct 28, 2013 at 3:50 PM
The filtering will occur based on the current data. You could add a check into your code and if the column is already populated, not make the function call.

M.
Oct 28, 2013 at 8:48 PM
Any code snippets to point me in the right direction of checking if the look up field is empty?
Coordinator
Oct 28, 2013 at 9:07 PM
It's a little tricky due to the fact that if you have 20+ options in the dropdown, SharePoint renders it as what I call a complex dropdown. That's made up of an input element with some script behind it. So, just like I have to in SPServices, you'll need to be able to handle a regular select (<20 options) and a complex select (20+ options).

M.
Oct 28, 2013 at 9:15 PM
Yes, I figured that's where the issue was. I kept getting the dreaded "object is null or defined." I've read your article addressing this issue. My values unfiltered would be 20+. So I'm assuming when the form first loads before executing the SPFilterDropDown, I need to handle it as if it's the Complex Select. I'm new to SPServices, so I'll go back to the documentation to read up a little more.
Coordinator
Oct 28, 2013 at 9:24 PM
If you know that you'll always be over 20 options, then you can use this selector:
$("input[Title='colName']")
M.
Oct 28, 2013 at 10:40 PM
Thanks! That helped. Darn complex selects! I had it figured out before I realized. It was conflicting with some other JavaScript functionality so I thought it wasn't working. I stripped out the other JavaScript and now it works. Now just have to figure out the conflict.