Timing issue: Autocomplete vs. Cascade

Forums Autocomplete Timing issue: Autocomplete vs. Cascade

Viewing 4 reply threads
  • Author
    Posts
    • #27330
      BenR
      Participant

      Alexander,

      I have a nearly working solution, with one last step failing…

      I have a two field Cascade, Tier-1: LOB, Tier-2: SubLOB. This is working fine.

      I also have Autocomplete, that upon selection, populates (setFields) both fields of the above Cascade, LOB and SubLOB – and this is where the problem lies. The Tier-1 LOB successfully populates every time, but the Tier-2 SubLOB does not. However, if I perform the Autocomplete a second time – the Tier-2 SubLOB is successfully populated.

      I think this is a subtle timing issue… It appears to me that the Tier-2 SubLOB field is not ready to receive the data from Autocomplete until Cascade sees the value in Tier-1 LOB. I’ve tried to turn off all options in Cascade to hopefully allow it to run faster (turned off Hide, Autofill, and Clear), but with no success.

      Here are the steps I take to fill the form with Autocomplete:

      1. From NewForm, I see that Cascade fields are shrunk in size as they are not yet populated (see image Step-1 below)
      2. Use Autocomplete, make Autocomplete selection – this will populate Tier-1 LOB field, but not Tier-2 SubLOB field (see image Step-2 below)
      3. Reperform Autocomplete – this time, Tier-2 SubLOB field is populated (see image Step-3 below)

      I realize that Autocomplete and Cascade may not be intended to used together, but is there a work-around possible to accomplish my objective?

      As always, I appreciate your support and efforts!

      R’grds – Ben.
      Reference:
      Version information

      DFFS Loader: v2
      DFFS frontend: 4.4.4.10 – September 20, 2019
      DFFS frontend CSS: 4.51 / 4.51
      Autocomplete: 1.6.37 – September 04, 2019
      Cascading dropdowns: 3.7.30 – July 21, 2019
      jQuery: 1.12.4
      Lookup: 1.1.17 – July 21, 2019
      Resource management: 2.4.5 – August 29, 2019
      SPJS-Utility: 1.337 – September 04, 2019
      vLookup: 2.2.138 – September 04, 2019

    • #27367
      Alexander Bautz
      Keymaster

      This is happening because when you set the first level casc it does a query to fetch the next level, but if you try setting both at the same time your second level casc will not find a valid option for the value you are trying to set.

      This might need some more custom code to work, but have a look at this newly added feature (you must update to v3.7.31 / DFFS v4.4.4.13 to use it): https://spjsblog.com/dffs/dffs-plugins/spjs-cascading-dropdowns/#Callback_function_when_select_is_filled

      See if you can use this somehow to make it work.

      Alexander

    • #27371
      BenR
      Participant

      Alexander,

      Yes – I believe your suggested Callback function will do the trick… However, I do need additional guidance.

      I have created an additional field, TemporarySubLOB, to capture the AutoComplete Tier-2:SubLOB value via setFields. When the Tier-2:SubLOB field is ready, I would like to move the value of TemporarySubLOB to it.

      
      
      // Set value to Cascade to address timing of Tier-2 (SubLOB)
      function spjs_casc_ready(id, readyFIN, index) {
          var config = spjs.casc.data[id];
          var filterValue = getFieldValue(config.thisListFields[(index - 1) > - 1 ? (index - 1) : index]);
          // Add your custom code here - like this example
          if (readyFIN === "SubLOB") {
              setFieldValue("SubLOB", "TemporarySubLOB");
          }
      };

      Do I just add the suggested function to Custom JS, or do I have to invoke it from a Rule? If I invoke it from a Rule, what parameters do I pass? I don’t see a id or index value in the Cascade debug information.

      As always, I really appreciate your support and efforts!

      R’grds – Ben.

    • #27376
      BenR
      Participant

      Alexander,

      Oh duh! Your suggestion took very little to get working – though my poor scripting skills slowed me down.

      The solution as you suggested worked perfectly! Thank you so much!

      R’grds – Ben.

    • #27381
      Alexander Bautz
      Keymaster

      I’m glad you got it working.

      Alexander

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