Auto Populate Values for field type Template Value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 10:01 AM
HI All,
I am trying to populate values in "template value" type of field using onChange script for target field(whenever we change target) .
when create a record and select a value of target table it populates value for if condition i.e 'active=true' but then when I try to change the target table to satisfy else condition it always give 'active=true' seems like what ever 1st value is set it does not replace with new value when changing the target table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 10:15 AM
Hello,
The issue you are facing is that when changing the target table after initially setting the value for the template_values field, the new value is not being applied.
code you provided only sets the value for the template_values field if it's a new record.
To update the value when the target table changes, you can modify your script as follows:
var targetTable = g_form.getValue('target_table'); var query = '';
if (targetTable == 'sc_task') { query = 'active=true'; }
else { query = 'short_description='; }
g_form.setValue('template_values', query);
I removed the g_form.isNewRecord() condition so that the value is set regardless of whether it's a new record or an existing one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 11:53 PM
HI Tushar, I have tried this earlier but its the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2025 12:15 PM
Were you able to find any solution ?