Set Value of Auto Complete

Home Forums Autocomplete Set Value of Auto Complete

Viewing 7 reply threads
  • Author
    Posts
    • #27488
      Wilson
      Participant

        Hi Alex,
        Is there a correct way to set the value of an Auto Complete field programmatically? If I set the value in Cutsom JS as below, it does not remove the “help text” or trigger the “set field” function of Auto Complete.

        setFieldValue("CustomerAccount",getFieldValue("CustomerAccountNew"));

        Thanks,
        Wilson

        Attachments:
      • #27511
        Alexander Bautz
        Keymaster

          Hi,
          Unfortunately you cannot use setFieldValue to set the value of a field enhanced with the autocomplete plugin. If you need to set it programatically you can try setting it BEFORE you call the spjs.ac function to enhance it – and use the reValidateOnLoad setting to have it automatically try to resolve the value.

          Alexander

          • This reply was modified 5 years ago by Alexander Bautz. Reason: See new comment below
        • #27553
          Alexander Bautz
          Keymaster

            Hi,
            I was wrong! – I did actually add this functionality earlier this year, but forgot to add it to the user manual for the AC plugin and only documented it in the ChangeLog.

            I have now updated the user manual with the correct function call to user.

            Sorry for the inconvenience.

            Alexander

          • #28564
            Filipe Ribeiro
            Participant

              Hi Alexander

              It works fine in case you’re not feeding other fields. I got the setFieldValue on Autocomplete working but the autocomplete does not update the others fields is using to fill up values thorough setFields 🙁 any suggestion ?

            • #28577
              Alexander Bautz
              Keymaster

                I’ll have to look into that and if it’s broken I’ll fix it in the next version.

                Alexander

              • #28654
                Alexander Bautz
                Keymaster

                  I have fixed a bug in the script and will try to get a new version of the DFFS package released later today.

                  Alexander

                • #28677
                  Alexander Bautz
                  Keymaster

                    Here is the new version: https://spjsblog.com/2020/02/13/dffs-package-updated-to-v4-4-4-23/

                    Let me know how it works out.

                    Alexander

                  • #34221
                    Jonathan Stamper
                    Participant

                      Does setFieldValue work for a multi-select AC? I’m trying to use the logic from the manual below but I may have it in the correct format for a multi-select.

                      spjs.ac.setFieldValue("AutocompleteFieldInternalName","The_Selected_Value");
                      • #34223
                        Alexander Bautz
                        Keymaster

                          Hi,
                          This does unfortunately only work on single choice autocompletes.

                          What exactly are you trying to do? – maybe you can use custom js to set the value before the autocomplete script is triggered – it should pick up the value as long as you have the correct format (correct separator between the values).

                          Alexander

                        • #34225
                          Jonathan Stamper
                          Participant

                            I’m doing light “data integrity” between what the requestor chooses in the main AC, and what is/isn’t available as a list item in a vLookup/child list. Only Admins can add to the vLookup/child list and I wanted to attempt to auto-update the AC values on the main form to reduce manual updating.

                            Right now, I have it set up where if a requestor adds items in the main AC field, when they save the request, the selections are then created as list items in the child list for additional usage and future reporting opportunities.

                          • #34240
                            Alexander Bautz
                            Keymaster

                              I’m not sure I understood exactly where you needed to set the field value of the AC, but if you have a set of values you need to set you can do it like this BEFORE you init the spjs.ac function:

                              setFieldValue("ACMulti","Test 1, Test 2");
                              
                              spjs.ac.textField({
                               "applyTo": "ACMulti",
                               ...
                               ...

                              Please note that the separator between Test 1 and Test 2 depends on on the separator you have specified in your spjs.ac.init function.

                              Alexander

                            • #34242
                              Jonathan Stamper
                              Participant

                                Ok, I’ll try that out. In terms of when/where the action would occur it would be after returning to the main form from child form and/or during dffs_ready and pre-save.

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