SPCascadeDropDowns not working if parent field required even with jquery.SPServices-2014.01.js

Mar 10, 2014 at 8:13 PM
Hi. I hit the "required field" issue after installing the SharePoint 2010 CU last week. I then modified one of my problem pages to use the 2014.01 update.:

<script type="text/javascript" src="/_layouts/jquery-1.11.0.js"></script>
<script type="text/javascript" src="/_layouts/jquery.SPServices-2014.01.js"></script>

The fix works fine where the parent field is NOTrequired but fails to "cascade" (filter) the results in the child lookup when the parent IS required. I have stepped through the debugger and was able to see that the parentSelect.Type is null and so the change/onchange event is not being bound.

Maybe I missed something?

We are using SP 2010 Foundation with the SharePiont 2010 CU.

I saw in the other postings that you needed the rendered html..... Here is ours:
<tr>
     <td nowrap="true" valign="top" width="190px" class="ms-formlabel"><h3 class="ms-standardheader">
        <nobr>SURVICE Site<span class="ms-formvalidation" title="This is a required field." > *</span></nobr>
    </h3></td>
        <td valign="top" class="ms-formbody">
        <!-- FieldName="SURVICE Site"
             FieldInternalName="SURVICE_x0020_Site"
             FieldType="SPFieldLookup"
          -->
            <span dir="none"><select name="ctl00$m$g_f9666e69_7a27_4008_839e_1cf5010f46f9$ctl00$coifieldlock1$ctl05$ctl00$ctl00$ctl04$ctl00$Lookup" id="ctl00_m_g_f9666e69_7a27_4008_839e_1cf5010f46f9_ctl00_coifieldlock1_ctl05_ctl00_ctl00_ctl04_ctl00_Lookup" title="SURVICE Site Required Field">
                    <option value="1">Operation 1</option>
                    <option value="2">Operation 2</option>
                    <option selected="selected" value="3">Operation 3</option>
                    .....
                </select><br/></span>
            
        </td>
    </tr>
    
        <tr>
        <td nowrap="true" valign="top" width="190px" class="ms-formlabel"><h3 class="ms-standardheader">
        <nobr>SURVICE Division</nobr>
    </h3></td>
        <td valign="top" class="ms-formbody">
        <!-- FieldName="SURVICE Division"
             FieldInternalName="SURVICE_x0020_Division"
             FieldType="SPFieldLookup"
          -->
            <span dir="none"><span style="vertical-align:middle"><input name="ctl00$m$g_f9666e69_7a27_4008_839e_1cf5010f46f9$ctl00$coifieldlock1$ctl06$ctl00$ctl00$ctl04$ctl00$ctl01" type="text" value="CORPORATE ADMINISTRATION" id="ctl00_m_g_f9666e69_7a27_4008_839e_1cf5010f46f9_ctl00_coifieldlock1_ctl06_ctl00_ctl00_ctl04_ctl00_ctl01" class="ms-lookuptypeintextbox" onfocusout="CoreInvoke('HandleLoseFocus')" opt="_Select" title="SURVICE Division" optHid="SPSURVICE_x0020_Division_Hidden" onkeypress="CoreInvoke('HandleChar')" onkeydown="CoreInvoke('HandleKey')" match="" choices="(None)|0|DIVISION 1|1|DIVISION 2|2|DIVISION 3|3|DIVISION 4|4|....." onchange="CoreInvoke('HandleChange')" /><img alt="Display lookup values" onclick="CoreInvoke('ShowDropdown','ctl00_m_g_f9666e69_7a27_4008_839e_1cf5010f46f9_ctl00_coifieldlock1_ctl06_ctl00_ctl00_ctl04_ctl00_ctl01');" src="/_layouts/images/dropdown.gif" style="border-width:0px;vertical-align:middle;" /></span><br/></span>
            
            
        </td>
    </tr>
Here is my script:
 $(document).ready(function(){
 /* Cascade drop downs */
  $().SPServices.SPCascadeDropdowns({
    relationshipList: "{B61486E8-6E9E-46A1-B630-DD245F37C048}",
    relationshipListParentColumn: "SURVICE_x0020_Site",
    relationshipListChildColumn: "Title",
    relationshipListSortColumn: "Title",
    parentColumn: "SURVICE Site",
    childColumn: "SURVICE Division",
    debug:true
  });
});
Any assistance would be greatly appreciated.
Mar 11, 2014 at 3:56 PM
While reviewing other pages in our site, I found two other list where we use the cascading drop downs, but they also add our "Team" selection under the Division.
EX: Site => Division => Team

"Site" and "Division" are both required. "Team" is not. With the 2014.01.js version, a selection of a "Site" (select) does not cascade to Division (complex drop down), all divisions are listed. However, the selection of a Division does cascade/filter the options in the "Team" (complex drop down).

NOTE: in the post above I have changes the relationshipListChildColumn to "SURVICE_x0020_Division". This is a minor change as this column and "Title" contain the same information, but I changes to keep consistent with implementations on other pages. Also removed the relationshipListSortColumn as it will default to the relationshipListChildColumn.

Here is the rendered HTML of the Site => Division => Team setup:
        <tr>
        <td nowrap="true" valign="top" width="190px" class="ms-formlabel"><h3 class="ms-standardheader">
        <nobr>SURVICE Site<span class="ms-formvalidation" title="This is a required field." > *</span></nobr>
    </h3></td>
        <td valign="top" class="ms-formbody">
        <!-- FieldName="SURVICE Site"
             FieldInternalName="SURVICE_x0020_Site"
             FieldType="SPFieldLookup"
          -->
            <span dir="none"><select name="ctl00$m$g_147d12b8_8feb_4b4c_9eab_7f3f26da87be$ctl00$coifieldlock1$ctl19$ctl00$ctl00$ctl04$ctl00$Lookup" id="ctl00_m_g_147d12b8_8feb_4b4c_9eab_7f3f26da87be_ctl00_coifieldlock1_ctl19_ctl00_ctl00_ctl04_ctl00_Lookup" title="SURVICE Site Required Field">
            <option value="1">Operation 1</option>
                    <option value="2">Operation 2</option>
                    <option selected="selected" value="3">Operation 3</option>
                    .....

                </select><br/></span>
            
            
        </td>
    </tr>
    
        <tr>
        <td nowrap="true" valign="top" width="190px" class="ms-formlabel"><h3 class="ms-standardheader">
        <nobr>SURVICE Division<span class="ms-formvalidation" title="This is a required field." > *</span></nobr>
    </h3></td>
        <td valign="top" class="ms-formbody">
        <!-- FieldName="SURVICE Division"
             FieldInternalName="SURVICE_x0020_Division"
             FieldType="SPFieldLookup"
          -->
            <span dir="none"><span style="vertical-align:middle"><input name="ctl00$m$g_147d12b8_8feb_4b4c_9eab_7f3f26da87be$ctl00$coifieldlock1$ctl20$ctl00$ctl00$ctl04$ctl00$ctl01" type="text" value="DIVISION 2" id="ctl00_m_g_147d12b8_8feb_4b4c_9eab_7f3f26da87be_ctl00_coifieldlock1_ctl20_ctl00_ctl00_ctl04_ctl00_ctl01" class="ms-lookuptypeintextbox" onfocusout="CoreInvoke('HandleLoseFocus')" opt="_Select" title="SURVICE Division" optHid="SPSURVICE_x0020_Division_Hidden" onkeypress="CoreInvoke('HandleChar')" onkeydown="CoreInvoke('HandleKey')" match="" choices="(None)|0|DIVISION 1|1|DIVISION 2|2|DIVISION 3|3|DIVISION 4|4|....." onchange="CoreInvoke('HandleChange')" /><img alt="Display lookup values" onclick="CoreInvoke('ShowDropdown','ctl00_m_g_147d12b8_8feb_4b4c_9eab_7f3f26da87be_ctl00_coifieldlock1_ctl20_ctl00_ctl00_ctl04_ctl00_ctl01');" src="/_layouts/images/dropdown.gif" style="border-width:0px;vertical-align:middle;" /></span><br/></span>
            
            
        </td>
    </tr>
    
        <tr>
        <td nowrap="true" valign="top" width="190px" class="ms-formlabel"><h3 class="ms-standardheader">
        <nobr>SURVICE Team</nobr>
    </h3></td>
        <td valign="top" class="ms-formbody">
        <!-- FieldName="SURVICE Team"
             FieldInternalName="SURVIC_x0020_Team"
             FieldType="SPFieldLookup"
          -->
            <span dir="none"><span style="vertical-align:middle"><input name="ctl00$m$g_147d12b8_8feb_4b4c_9eab_7f3f26da87be$ctl00$coifieldlock1$ctl21$ctl00$ctl00$ctl04$ctl00$ctl01" type="text" value="TEAM 4" id="ctl00_m_g_147d12b8_8feb_4b4c_9eab_7f3f26da87be_ctl00_coifieldlock1_ctl21_ctl00_ctl00_ctl04_ctl00_ctl01" class="ms-lookuptypeintextbox" onfocusout="CoreInvoke('HandleLoseFocus')" opt="_Select" title="SURVICE Team" optHid="SPSURVIC_x0020_Team_Hidden" onkeypress="CoreInvoke('HandleChar')" onkeydown="CoreInvoke('HandleKey')" match="" choices="(None)|0|TEAM 1|1|TEAM 2|2|TEAM 3|3|TEAM 4|4|TEAM |5|TEAM 6|6|TEAM ....." onchange="CoreInvoke('HandleChange')" /><img alt="Display lookup values" onclick="CoreInvoke('ShowDropdown','ctl00_m_g_147d12b8_8feb_4b4c_9eab_7f3f26da87be_ctl00_coifieldlock1_ctl21_ctl00_ctl00_ctl04_ctl00_ctl01');" src="/_layouts/images/dropdown.gif" style="border-width:0px;vertical-align:middle;" /></span><br/></span>
            
            
        </td>
    </tr>
The scripts:
    $(document).ready(function() {
        $().SPServices.SPCascadeDropdowns({
            relationshipList: "{B61486E8-6E9E-46A1-B630-DD245F37C048}",
            relationshipListParentColumn: "SURVICE_x0020_Site",
            relationshipListChildColumn: "SURVICE_x0020_Division",
            parentColumn: "SURVICE Site",
            childColumn: "SURVICE Division"
        });
     
        $().SPServices.SPCascadeDropdowns({
            relationshipList: "{2BD93A3C-665C-45BB-9C52-239629052ED9}",
            relationshipListParentColumn: "SURVICE_x0020_Division",
            relationshipListChildColumn: "SURVICE_x0020_Teams",
            parentColumn: "SURVICE Division",
            childColumn: "SURVICE Team"
                    });
        });
Apr 3, 2014 at 5:58 PM
Edited Apr 3, 2014 at 6:24 PM
Hey jreddell145,
I'm having this same issue. Just to get your script running you can change the relationshipListParentColumn: "SURVICE_x0020_Division" to relationshipListParentColumn: "SURVICE_x0020_Division Required Field". and spservices will find what it needs. At least in my case it did.

Another jack I've got working is just adding this at the beginning of my code :

$( "select[Title$=' Required Field']" ).each(function(){
    $(this).attr("Title", $(this).attr("Title").split(" Required Field")[0]);
});
$("input[Title$=' Required Field']").each(function () {
    $(this).attr("Title", $(this).attr("Title").split(" Required Field")[0]);
});



Mark,
I installed SP2 On Prem about 2 weeks ago and everything was fine. Then I discovered my workflows were not starting, so I applied the December 2013 CU. THAT is when the reuired field issue occurred -- somewhere between SP2 and the December 2013 CU.
May 16, 2014 at 9:36 PM
I'm running into this same thing. Using jquery-1.10.2.min.js & jquery.SPServices-2014.01.js

Here is my call $(document).ready(function()
{
console.log("starting spcascade dropdown setup");
$().SPServices.SPCascadeDropdowns({
  relationshipWebURL: " ",
  relationshipList: "{ACBA409D-742D-4A96-A927-1518FA932069}",
  relationshipListParentColumn: "The_x0020_Site",
  relationshipListChildColumn: "Title",
  relationshipListSortColumn: "",
  parentColumn: "The Site",
  childColumn: "Info Needs #",
  CAMLQuery: "",
  listName: $().SPServices.SPListNameFromUrl(), 
  simpleChild: false, // Added in v0.6.2
  selectSingleOption: false, // Added in v0.6.2
  completefunc: function(){console.log("done")},
  debug: true
});
});

And here is the html for the parent column:

<SELECT name=ctl00$m$g_d64f3166_cbd0_41eb_82e0_4314c09fe213$ff12_1$ctl00$Lookup title="The Site Required Field" id=ctl00_m_g_d64f3166_cbd0_41eb_82e0_4314c09fe213_ff12_1_ctl00_Lookup>
<OPTION value=6 selected>.....</OPTION>
</SELECT>

I stepped through the spservices code and I think the problem is happening on line 3977:
if ((columnObj.Obj = $("select[Title='" + opt.displayName + "']")).length === 1)
since the title (The Site Required Field) doesn't equal the display name (The Site) exactly it doesn't find it.

Looks like russgove's hack to remove all the Required Field's from the title's is the way to go.
Sep 16, 2014 at 4:37 PM
Having this exact issue as well. Anyone find a fix? This post helped me work around the issue, but the customer would really like their cascading drop down fields required.

SharePoint 2010; SPServices 2014.01; jQuery v1.11.0
Sep 16, 2014 at 4:43 PM
The fields can still be required, russgove's script just changes the title attribute of your required field so the SPCascadeDropdowns script works. It is still required on the back end.
Coordinator
Sep 16, 2014 at 4:58 PM
I lost this thread somewhere along the way.

I have a fix for this in the latest alpha of 2014.02. If you'd like to try it, I'd appreciate it if you could let me know if it works for you.
https://spservices.codeplex.com/releases/view/119578

M.
Marked as answer by jreddell145 on 12/2/2014 at 5:37 AM
Coordinator
Sep 16, 2014 at 5:00 PM
p.s. See this item in the Issue Tracker:
https://spservices.codeplex.com/workitem/10284

M.
Dec 1, 2014 at 9:59 PM
Thank you for the update sympmarc! It took me a while to get back to this. Sorry.

The 2014.02BETA1 changes have corrected my issues. Thanks again!
Coordinator
Dec 2, 2014 at 2:46 PM
Great! Appreciate the follow up.

M.