set fields from source list

Home Forums Cascading dropdowns set fields from source list

Viewing 8 reply threads
  • Author
    Posts
    • #32292
      Tony
      Participant

        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
        }
        );

      • #32294
        Alexander Bautz
        Keymaster

          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

        • #32296
          Tony
          Participant

            Hi Again,

            All names are correct (fieldinternalname)
            CustomerDesignation is a single line of text

            Tony

          • #32298
            Tony
            Participant

              I also tried to use the cascading tab instead of custom js but same result

            • #32300
              Alexander Bautz
              Keymaster

                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

              • #32302
                Tony
                Participant

                  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

                • #32304
                  Tony
                  Participant

                    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;
                    }
                  • #32306
                    Alexander Bautz
                    Keymaster

                      I’ll look into this tomorrow and see if I can figure out what is going on.

                      Alexander

                    • #32316
                      Alexander Bautz
                      Keymaster

                        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

                    Viewing 8 reply threads
                    • You must be logged in to reply to this topic.