Home › Forums › Autocomplete › Set Value of Auto Complete
Tagged: autocomplete, multiselect, set value
- This topic has 11 replies, 4 voices, and was last updated 3 years, 4 months ago by Jonathan Stamper.
-
AuthorPosts
-
-
October 28, 2019 at 16:39 #27488
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,
WilsonAttachments:
-
October 29, 2019 at 19:07 #27511
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, 1 month ago by Alexander Bautz. Reason: See new comment below
-
November 2, 2019 at 09:32 #27553
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
-
February 6, 2020 at 19:02 #28564
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 ?
-
February 7, 2020 at 15:16 #28577
I’ll have to look into that and if it’s broken I’ll fix it in the next version.
Alexander
-
February 13, 2020 at 11:39 #28654
I have fixed a bug in the script and will try to get a new version of the DFFS package released later today.
Alexander
-
February 13, 2020 at 20:33 #28677
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
-
August 3, 2021 at 00:05 #34221
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");
-
August 3, 2021 at 15:28 #34223
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
-
August 3, 2021 at 22:02 #34225
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.
- This reply was modified 3 years, 4 months ago by Jonathan Stamper.
-
August 4, 2021 at 14:53 #34240
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
-
August 4, 2021 at 18:41 #34242
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.
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.