SP3 (for SharePoint 2010) broke my SPCascadeDropdowns

Apr 24, 2014 at 5:36 PM
Hello,

I just installed SP3 (i know, I'm a little late) and it seems to have broken my SPCascadeDropdowns...

The js error I'm getting is on line 1476 of jquery.SPServices-2014.01.js "Uncaught TypeError: Cannot read property 'push' of null". Here is the related code:
 // If this is the first child for this parent, then create the data object to hold the settings
        if (typeof childColumns === "undefined") {
            parentSelect.Obj.data("SPCascadeDropdownsChildColumns", [childColumn]);
            // If we already have a data object for this parent, then add the setting for this child to it
        } else {
            childColumns.push(childColumn);
            parentSelect.Obj.data("SPCascadeDropdownsChildColumns", childColumns);
            thisParentSetUp = true;
        }
To me, that looks like the "ChildColumns" object is not fully initialized yet, so I tested that theory. I added a "alert(typeof childColumns); right before the block above, and the first time it is encountered it is returning 'object' rather than 'undefined'.

I'm not sure if this is conclusive on anything, and I'm not familiar enough with this code to confidently tweak it, so I thought I would see if any of the contributors to this project know what could be happening here.

Of course, let me know what other information could be helpful in figuring this out. The key seems to be that upgrading to SP2 coincided with this feature breaking.
Apr 25, 2014 at 2:10 AM
Place this alert instead:

alert(typeof childColumns);

Object is ok. But at that point in the code, it better be an array or else you get the error you are seeing.
Also, what version of Sharepoint are you on?


--
Paul T.

-- Sent from Mobile

Apr 25, 2014 at 2:04 PM
That is the same alert I did try. The result is still "object". As mentioned, this error started when I upgraded SharePoint 2010 from SP1 to SP2.

Thanks for helping out with this.

--mobrien118
Apr 25, 2014 at 7:45 PM
Ok. So that is the problem, but I'm sure Mark will want more to figure out what's going on.

Can you get the output this alert (this will only work from a browser that supports JSON object (ie8 and above):

alert( JSON.stringify( childColumns ) );

Also, I though I have seen this same issue reported here in the past. Search around.

One last question: are executing your code inside a "dom ready" function?


Paul



--
Paul T.

-- Sent from Mobile

Apr 25, 2014 at 10:16 PM
Edited Apr 25, 2014 at 10:17 PM
That alert returns "null" right before the function errors out. I'm using Chrome (newest) and have some experience writing and debugging JavaScript, although it has been a while since I have. The error is the same (although reported differently) in IE11.

DOM Ready: Yes, the code is wrapped in "$(document).ready(function() {" and it WAS working for over a year on SP1 of SharePoint 2010. This only started happening after upgrading to SP2. ,,_ My code that calls "$().SPServices.SPCascadeDropdowns".

In fact, here is my code:
<script type="text/javascript"> 
    $(document).ready(function() {
        $().SPServices.SPCascadeDropdowns({
            relationshipList: "{902421AC-9B8C-41D5-9452-EA2B71EB43E8}",
            relationshipListParentColumn: "Department",
            relationshipListChildColumn: "Title",
            parentColumn: "Department_",
            childColumn: "Category_",
            simpleChild: true,
            debug: true
        });
        $().SPServices.SPCascadeDropdowns({
            relationshipList: "{7CFFAF21-F75F-4D6B-897B-A1B461B47389}",
            relationshipListParentColumn: "Category",
            relationshipListChildColumn: "Title",
            parentColumn: "Category_",
            childColumn: "Sub-Category_",
            simpleChild: true,
            debug: true
        });
//    alert("jQuery loaded");
    });
</script>
Apr 25, 2014 at 10:56 PM
Good info. How ever Marc is initiating childColumns is coming up as null. I don't have the code in front of me, but hang in there, Marc will get around to this.


--
Paul T.

-- Sent from Mobile

Coordinator
Apr 30, 2014 at 7:49 PM
I think you may be running into this issue:
http://sympmarc.com/2014/01/23/office-365-update-changes-display-name-on-required-fields/

My guess is that the Category_ and/or Sub-Category_ columns may be required. It would be really helpful to me if you could post the markup from the browser for the column which is causing the problem. I thought that I had put a valid fix for SharePoint 2010 into 2014.01, but I've had a few reports of issues.

See:
https://spservices.codeplex.com/workitem/10256
https://spservices.codeplex.com/workitem/10250
https://spservices.codeplex.com/workitem/10231

M.
May 1, 2014 at 2:12 PM
That is exactly what is happening. I changed the code to include " Required Field" and now they are working again sort of.

One other difference now is that "(none)" shows up as the default option for the lookup drop-downs. This is, obviously, an invalid value and will confuse my users.

I upgraded SpServices and jQuery during my attempt to fix this issue. Is this something new I need to account for? I'll go back to the documentation, but if you see this before I figure it out, would you please let me know?

Thanks!
May 1, 2014 at 2:35 PM
OK, so I went back to the documentation (specifically here) and found your (Marc's) comment at the bottom of the comments: "The None option is present if the column value is not required. Change the column to required, and the None value will be gone. M.".

This appears to be broken as my fields are required fields but are still showing the "(none)" option. If you select "(none) as a value for one of them, the form will still submit, but throws an unhandled sharepoint error. Is this related to the overall issue of the fields changing like that, or am I doing something else wrong?

Thanks!
May 14, 2014 at 9:14 AM
Having the exact situation as you, only the unhandled exception when submitting (none) values in required fields is only occurring when using cascade dropdowns in calendar lists.
I also still need to user the 'required field' when using the 2014-1 version of spservices.
I'm in Office 365 (SP 2013)

You could use custom JavaScript/jQuery client side validation as an alternative to SharePoint's validation since it's not ideal anyway. Especially when using required lookup columns.
May 15, 2014 at 9:36 PM
maunx wrote:
You could use custom JavaScript/jQuery client side validation as an alternative to SharePoint's validation since it's not ideal anyway. Especially when using required lookup columns.
I could do that, but if there is going to be a fix in an upcoming version of SPServices, I would rather wait for that (Unfortunately, I already have a long list of other code I need to write)

I don't mind helping to contribute to a solution to the root cause, though. Please let me know what I can do to help (troubleshooting-wise).

Thanks,

--mobrien118
Coordinator
May 15, 2014 at 9:41 PM
I've sort of lost the thread here. It sounds like it's an issue where "(None)" is shown as an option in SharePoint 2010 when SP2 has been applied and the column is not required? Is it that specific or something more widespread?

M.
May 16, 2014 at 12:10 PM
Edited May 16, 2014 at 12:10 PM
The original issue was with the " Required Field" being added to the fields in SP2, however, during the course of troubleshooting, I upgraded to the latest version of SPServices, which fixed the fields, however, the (none) issue started happening.

So: the (none) showing up for required fields could have been caused by 2 different things in my case:
  1. upgrading to SPServices 2014-1
  2. upgrading to SharePoint SP2
I'm not sure which one triggered it. I guess I could go back to the old version of SPServices and see if it still happens and then post back. I will do it later in the day today, since I only have a production environment (no test) at the moment.

Thanks,

--mobrien118
Jun 18, 2014 at 10:12 PM
Sorry, I'm not usually one to bump a thread, but it has been a month and I'm wondering if anyone else is having this issue or if it's just me.

Again, the issue is that the (none) option is showing up for required fields where, before, it was not.

Thanks,

--mobrien118
Coordinator
Jun 18, 2014 at 10:43 PM
Edited Aug 20, 2014 at 3:32 AM
Did you revert back to an older version of SPServices? I haven't replied since you said you were going to try that.

M.
Jul 3, 2014 at 6:15 PM
I am having the same issue as mobrien118 with version jquery.SPServices-2014.01 and I reverted back to jquery.SPServices-2013.02a to test and the issue is the same but the error throws on line 1407(childColumns.push(childColumn);) instead.
Coordinator
Aug 20, 2014 at 3:32 AM
Edited Aug 20, 2014 at 3:33 AM
DHowellBrevard:

Can you explain which "same" issue you are having and provide some more specifics? I'm having trouble figuring out if there is an issue here and what it is because the specifics are spotty across all of the posts.

M.
Sep 9, 2014 at 9:40 PM
I was finally able to confirm that this bug is NOT present in version 0.7.2 using jquery 1.8.3.

It IS present in version 2014.01 using jquery 1.10.1.

Again, the issue is that "(null)" shows up in a required lookup field using SPServices.
Sep 17, 2014 at 7:41 PM
Let me know if there is any information I can get to you to help fix this regression bug. I would assume you would like it fixed before the next release. I also would like to use a newer version of jquery so, like I said, I'm here to help!
Coordinator
Sep 17, 2014 at 7:53 PM
Can you try the latest alpha of 2014.02?
https://spservices.codeplex.com/releases/view/119578

Let me know what line throws an error if it still does and post your call to the function. I'll try to figure it out with you.

M.
Sep 18, 2014 at 3:20 PM
Sure! What version of JQuery should I use with it?

Just to point out., there is no error thrown. It simply includes "(none)" even when the field is a required field. It happens in 2014.01 but not in 0.7.2.

Thanks!
Sep 18, 2014 at 3:26 PM
Update: I just tried the ALPHA3 with the form and it is still showing "(none)" as an option for the required lookup field(and accepting it as valid input). This is with these libraries:
<script language="javascript" type="text/javascript" src="/stations/SiteAssets/jquery-1.10.1.js"></script>
<script language="javascript" type="text/javascript" src="/stations/SiteAssets/jquery.SPServices-2014.02ALPHA3.js"></script>
Coordinator
Sep 18, 2014 at 8:25 PM
Did you remove the " Required Field" from your field name(s)?

M.
Sep 30, 2014 at 3:39 PM
sympmarc wrote:
Did you remove the " Required Field" from your field name(s)?
Honestly, I'm not sure what you mean. I didn't remove anything from the field names, but I don't see any "Required Field" in any part of the field name in any place I can look. Can you be more specific as to where you are talking about? Keep in mind that this works in version 0.7.2 of SPServices.