Copy link to clipboard
Copied
I am working on a combobox that is one of several inputs that populate a one field. I use the SetFieldValues to achieve this.
if (level.value>=3){
SetFieldValues(event.value)
function SetFieldValues(cName){
if (this.getField("Other Proficiencies").value !=="")
{this.getField("Other Proficiencies").value= this.getField("Other Proficiencies").value += "," + LangProf[cName].prof;}
else
{this.getField("Other Proficiencies").value=LangProf[cName].prof;}}}
My first issue is that I have to recommit the combobox value to trigger the function. I am looking for a way to have it read the value already present and add accordingly without overwritting the target field.
My second issue is when the value changes, the previous string remains in the field. I don't mind deleting it but if there is a way to do it automatically, it would have multiple applications for my project.
Thanks for reading and also for any help!
Use event.change, and check that event.willCommit equals false first.
Copy link to clipboard
Copied
Where did you place the code?
Did you make sure to tick the option to commit the selected value of the drop-down field immediately?
Copy link to clipboard
Copied
I have it placed on the combobox under custom keystroke and the value is commited immediately. I just realized if the correct user value is present, and then I switch to any new value, that is when the string will pop up. It seems to ignore the current value and waits for the next value to be selected.
Copy link to clipboard
Copied
Use event.change, and check that event.willCommit equals false first.
Copy link to clipboard
Copied
Thank you for the advice! This sounds like the way forward. I will do my reading to see what I can do.
Is there a way to remove the string after the fact? I was thinking I could just subtract LangProf[cName].prof but that sounds like it would just cancel out rather than undo.
Copy link to clipboard
Copied
You can simply delete the contents of the field.
Copy link to clipboard
Copied
I have tried to implement this advice but cannot seem to wrap my head around it. Considering the code I provided in the original post, how would you amend it with !event.willCommit and event.rc? I don't mean to waste any of your time but the resources I find online are beyond my ken. Thank you for the help you have already given.
Copy link to clipboard
Copied
Just move the code to the Validation event, it's easier...
Copy link to clipboard
Copied
I will try this. Thank you again for the response.