autopopulate field depending on another field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2024 05:31 AM - edited ‎11-13-2024 05:35 AM
Hello,
I am tasked to fix a bug on a client script that when the field "please_provide_a_number" is inputted, the field "a_number" should be auto populated with the same input. I created a client script, but I believe it is not triggering due to Initial script. Should i add a default value on the table to autopopulate the field from the app studio? If so what would be the best way of going about this. Below is scripts:
initial script:
variable name: please_provide_a_number
second script to check if a_number field has been filled, if not populate...
variable name: please_provide_a_number

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2024 06:09 AM
My guess, without seeing your Script Include script from your Ajax call, is that you are having a script order issue. You have two onChange client scripts running onChange on the same field. So you don't know which one will run first unless one has a higher order to run later. Can you post a screenshot of your script include method you are calling, the one named ,alienNumCCHT?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2024 06:21 AM
Instead of a second onChange script on the same field, just replace the setValue line for 'a_number' in the 'initial script':
if (ans.aNum) {
g_form.setValue('a_number', ans.aNum);
} else {
g_form.setValue('a_number', newValue);
}