Copy link to clipboard
Copied
I am trying to use a custom validation script (or a custom keystroke script - whatever is best) in a drop-down to set the items in another drop-down based on the display value (not the export value). If I use the export value, it works without issue. If I use the display value, it is always one step behind the selection. I am using the following validation script in Dropdown1:
if(event.target.getItemAt(event.target.currentValueIndices, false)=="A")
{
this.getField("Dropdown2").setItems(["aa","aaa"])
}
if(event.target.getItemAt(event.target.currentValueIndices, false)=="B")
{
this.getField("Dropdown2").setItems(["bb","bbb"])
}
When I select "A" in dropdown one, it sets the items as if I selected "B" and vice versa.
Copy link to clipboard
Copied
In the Validation event the new value has not been committed to the field yet (it's still being validated, after all), so accessing the field's value property will return the old value, not the new one. To access the new value you should use event.value.
Copy link to clipboard
Copied
event.value works but it pulls the export value. I need the display value. Is there a way to do this?
Copy link to clipboard
Copied
It's tricky. The only way I found is to loop over all the items (using numItems and getItemAt), comparing them to the selected value, and then getting the display value by using getItemAt, but this time with the bExportValue parameter set to false.
Copy link to clipboard
Copied
I agree, that's the only way you can do it. It's a bit more programming effort, but you do it once, and then use it whenever you need it.
Copy link to clipboard
Copied
Thank you.
Copy link to clipboard
Copied
Thank you.
Copy link to clipboard
Copied
When the custom keystroke event handler gets executed, the target field has not yet been updated. That's why you are getting the previous value. You need to access the modified value via event.value: Acrobat DC SDK Documentation - event.value
Find more inspiration, events, and resources on the new Adobe Community
Explore Now