Home › Forums › Cascading dropdowns › set fields from source list
- This topic has 8 replies, 2 voices, and was last updated 3 years, 12 months ago by Alexander Bautz.
-
AuthorPosts
-
-
December 22, 2020 at 08:48 #32292
Hi Alex,
Cascading is working perfectly but i am not abllt to make the setfields work as expected.
below is my code. the destination field is not set once all cascading values are filled. I even tried with s simple one level cascading.
Any help will be really appreciated.spjs.casc.init(
{
“manualMode”: true,
“dataSource”: “”,
“lookupList”: “Projects”,
“lookupListBaseUrl”: “/Administration”,
“lookupListFields”: [“Company/Title”,”ProjectType/Title”,”Title”,”Product/Title”],
“thisListFields”: [“CompanyString”,”StatusOfVisitString”,”ProjectString”,”ProductString”],
“setFields”: [{“from”: “CustomerDesignation”,”to”: “CustomerDesignation”,”parseFunction”: “”}],
“dropDownDefaultvalue”: “Select…”,
“filter”: “”,
“hideEmptyDropdowns”: false,
“autoselectSingleOption”: true,
“clearInvalidSelection”: false,
“addOwnValue”: false,
“addOwnValueMouseover”: “”,
“cancelOwnValueMouseover”: “”,
“sideBySide”: true,
“multichoiceDelimiter”: “;\d”,
“debug”: false
}
); -
December 22, 2020 at 10:24 #32294
Ensure you have the correct field name in the “to” in your setFields config – a wrong field name here will not throw an error.
If the field name is correct – what kind of field is CustomerDesignation? – you might need to use the parseFunction setting to use a function to modify the value to the correct format before setting the value.
Alexander
-
December 22, 2020 at 10:48 #32296
Hi Again,
All names are correct (fieldinternalname)
CustomerDesignation is a single line of textTony
-
December 22, 2020 at 10:48 #32298
I also tried to use the cascading tab instead of custom js but same result
-
December 22, 2020 at 13:06 #32300
Which version of cascading dropdown script do you use? (hover over the Enhanced with DFFS link below the form and click the License and version information link).
This feature was added in SPJS-Casc v3.7.37 on March 27, 2020.
You can try using the parseFunction to “look” at the value in the setFields by adding it like this (please note it will alert one time per item – change it to console.log if you have a lot of items):
"setFields": [{"from": "CustomerDesignation","to": "CustomerDesignation","parseFunction": "myParseFn"}],
Then add this to your Custom JS:
function myParseFn(val) { alert(val); return val; }
Alexander
-
December 22, 2020 at 13:24 #32302
The strange thing is I already tried a myParseFn with alert and it is not called at all it seems. No alert received after all levels of cascading are filled.
Version used is 3.7.41 August 30
-
December 22, 2020 at 13:26 #32304
Complete custom JS:
spjs.casc.init( { "manualMode": true, "dataSource": "", "lookupList": "Projects", "lookupListBaseUrl": "/Administration", "lookupListFields": ["Company/Title","ProjectType/Title","Title","Product/Title"], "thisListFields": ["CompanyString","StatusOfVisitString","ProjectString","ProductString"], "setFields": [{"from": "CustomerDesignation","to":"CustomerDesignation","parseFunction": "myParseFn"}], "dropDownDefaultvalue": "Select...", "filter": "", "hideEmptyDropdowns": false, "autoselectSingleOption": true, "clearInvalidSelection": false, "addOwnValue": false, "addOwnValueMouseover": "", "cancelOwnValueMouseover": "", "sideBySide": true, "multichoiceDelimiter": ";\d", "debug": false } ); function myParseFn(val) { alert(val); return val; }
-
December 22, 2020 at 19:37 #32306
I’ll look into this tomorrow and see if I can figure out what is going on.
Alexander
-
December 23, 2020 at 15:04 #32316
Hi,
Are you using multiple instances of cascading dropdowns from the Projects list in this form? – in this case you must read the important information on the help icon on the “Comma separated list of fields in the lookup list” heading. This basically tells that you must include ALL fields you plan to use (also the setFields “from” field) in this textarea) – this because of how spjs-casc only queries the list ONE time even if you have multiple sets of cascading dropdowns in the same form to avoid unnecessary load on the server.If you add the function call to your custom js and specify “manualMode”: true this is not a problem, but ensure you don’t also have the same exact config in the cascading dropdown tab as this will interfere.
Let me know if you still have trouble.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.