Timing issue: Autocomplete vs. Cascade

Forums Autocomplete Timing issue: Autocomplete vs. Cascade

Viewing 9 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

    • #37648
      BenR
      Participant

      Alexander,

      Returning to this issue 5-years later…

      I have a 5-tier Cascading Dropdown set on the Cascading dropdowns menu in DFFS – this is working perfectly (SCLOB1, SCLOB2, SCLOB3, SCLOB4, SCLOB5).

      Added to this, I am using Autocomplete which will write to these Cascading Dropdown fields. In the past, the timing issue of Cascading vs. Autocomplete was circumvented with this guidance: https://spjsblog.com/dffs/dffs-plugins/spjs-cascading-dropdowns/#Callback_function_when_select_is_filled. However, it seems not to be working… To support Autocomplete, I move values into LOB2Temp, LOB3Temp, LOB4Temap, and LOB5Temp. Then, use function spjs_casc_ready() to move those values into the Cascading Dropdown fields.

      This has worked well in the past… I have attached the code for Autocomplete and function spjs_casc_ready() – do you see anything wrong?

      As always, your support and efforts are greatly appreciated!

      R’grds – Ben.
      Reference:
      Version information

      Custom DFFS-folder: DFFS_v4.4.5.50_2024-04-05
      DFFS Loader: v2
      DFFS frontend: 4.4.5.40 – April 04, 2024
      DFFS frontend CSS: 4.65 / 4.65
      Autocomplete: 1.6.56 – April 04, 2024
      Cascading dropdowns: 3.7.48 – September 22, 2021
      jQuery: 3.6.3
      Lookup: 1.1.20 – March 10, 2020
      Resource management: 2.4.5 – August 29, 2019
      SPJS-Utility: 1.356 – November 20, 2021
      vLookup: 2.2.166 – April 04, 2024

      Licensed to

      …..

    • #37650
      BenR
      Participant

      Alexander,

      Additional clarification… The first tier of the Cascading dropdown successfully populates. The second tier and on down to fifth tier do not populate (this is where the timing function spjs_casc_ready() should come into play).

      There are no errors reported in Console, tested in Edge (IE mode) and Google Chrome.

      R’grds – Ben.

    • #37651
      Alexander Bautz
      Keymaster

      This is hard to replicate without having the exact same setup in the list.

      Did it stop working when you updated to a new DFFS version?

      I’m not sure exactly how you use the AC and the CASC in the form, but if you always start with the AC you should wait to initialize the CASC until the AC has completed filling the fields – then the CASC should populate correctly when initialized.

      Alexander

    • #37652
      BenR
      Participant

      Alexander,

      Your simple rule – AC, then CASC – worked! I moved the CASC into Custom JS below AC and found it working as I need.

      As always, your support and efforts are SO appreciated!

      R’grds – Ben.

    • #37653
      Alexander Bautz
      Keymaster

      Thanks for the feedback – I’m glad it worked.

      Alexander

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