Set the value of a Cascading dropdown field

Forums Cascading dropdowns Set the value of a Cascading dropdown field

Tagged: 

Viewing 5 reply threads
  • Author
    Posts
    • #27313
      Therman
      Participant

      Is this possible?
      I currently have this CustomJS running:

      spjs.casc.init(
       {
       "manualMode":true,
       "dataSource":"",
       "lookupList":"LL_Centers",
       "lookupListBaseUrl":"{currentsite}",
       "lookupListFields":["Command","Title"],
       "thisListFields":["EventCommandLookup","EventOrgLookup"],
       "dropDownDefaultvalue":"Select...",
       "filter":"",
       "hideEmptyDropdowns":false,
       "autoselectSingleOption":true,
       "clearInvalidSelection":false,
       "addOwnValue":false,
       "addOwnValueMouseover":"",
       "cancelOwnValueMouseover":"",
       "sideBySide":false,
       "debug":false
       }
      );

      Works fine, but when I create a rule that sets the EventCommandLookup field to a value, it doesn’t work. How do I identify values for the Cascading dropdowns?

      • This topic was modified 4 years, 9 months ago by Therman.
    • #27318
      Therman
      Participant

      So it looks like “EventCommandLookup” is working like normal. I actually had my value misspelled. But “EventOrgLookup” isn’t working.

    • #27322
      Alexander Bautz
      Keymaster

      Setting a cascading dropdown field is easiest done before the cascading dropdown function is initiated – values are then automatically set if the script finds the values as valid options.

      If you want to set it after it is initiated you must first ensure the field is filled with the available options, and then set the value using:

      setFieldValue("your_field_name","the_selected_value");

      The problem is that when selecting the first level, the function to retrieve the options for the next level needs some time to finish before you can set the next value.

      I’ll include a callback function in the next release that lets you trigger a function when the values for the next level is ready.

      Alexander

    • #27324
      Therman
      Participant

      How would I write that line of code you suggested on the rules tab? Do I choose my field from the drop-down and write your suggestion in the value field?

    • #27328
      Alexander Bautz
      Keymaster

      This code must be added in Custom JS. Create a function with your code and call it from Run these functions / trigger these rules in a rule.

      Alexander

    • #29874
      Ezra Goodnoe
      Participant

      Alex, have you implemented the callback on the getFieldValue function?

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