This project has moved and is read-only. For the latest updates, please go here.

Set initial value of lookup field with SPServices.SPCascadeDropdowns

Sep 9, 2013 at 10:28 AM
I use SPServices.SPCascadeDropdowns to link two lookup fields in a custom NewForm for a custom list.

What I want to do is give an option to create a new item, based on a currently created item, and I have all the values for the previous item available, but I have a hard time setting the values of the lookup fields which are using SPCascadeDropdowns to a given value.

I found that I could use the following to change the value of the fields:
This seems to work on the parent column of the SPCascadeDropdowns, but even though it changes the value, it doesnt seem like it triggers the change for SPCascadeDropdowns, because the child column does not get updated according to the change in parent.

    relationshipList: "ChildList",

    relationshipListParentColumn: "ParentValue",
    relationshipListChildColumn: "Title",

    parentColumn: "ParentLookupField",
    childColumn: "ChildLookupField",

    simpleChild: true,

    completefunc: function () {
            $("select").each(function (index, item) {
                var title = item.title;
                if (title === ""ParentLookupField"," || title === ""ChildLookupField",") {
                    $(item).find("option").each(function (index, item) {
                        var text = $(item).text();
                        if (text === "(None)") {

So, how can I with SPCascadeDropdowns set the initial value of the lookup fields and make SPCascadeDropdowns trigger changes for the child field?
Sep 9, 2013 at 2:57 PM
SPCascadeDropdowns itself won't help you with this, but writing your own code in the completefunc is the right way to go, as you are doing.

The complication is the different ways that SharePoint renders the dropdowns based on the number of options. You may be looking at what I call a "complex" dropdown if you have 20+ options. In that case, setting the value is a little trickier. You can see how I do it in the function itself.