- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 05:04 PM
When a value is selected in a reference type item, I want to display another item of the record selected in the reference type item in a read-only string column.
reference_column_a : Reference type item
reference_column_b: Display another item of the record selected in the reference type item
Currently, it is executed using a client script, and sys_id is returned to reference_column_b.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var reference_column_a = g_form.getValue('reference_column_a');
g_form.setValue('reference_column_b', reference_column_a);
}
It would be helpful if you could tell me how.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 08:44 PM
Hi @user_ms
If you're working with Catalog Item, you can leverage the Auto-populate feature within the Variable configuration.
In the other hand, you can do an AJAX call > query to the table of the first reference field > get the value sys_id of the second reference field.
You're also able to achieve this using the below API.
getReference(String fieldName, Function callBack)
Sample.
function onChange(control, oldValue, newValue, isLoading) {
g_form.getReference('<reference_field_1>', populateValue); // doAlert is our callback function
}
function populateValue(reference_field_1) { // reference is passed into callback as first arguments
g_form.setValue('<field_name>', reference_field_1.getValue('<reference_field_2>'));
}
Let me know if it works for you.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 08:44 PM
Hi @user_ms
If you're working with Catalog Item, you can leverage the Auto-populate feature within the Variable configuration.
In the other hand, you can do an AJAX call > query to the table of the first reference field > get the value sys_id of the second reference field.
You're also able to achieve this using the below API.
getReference(String fieldName, Function callBack)
Sample.
function onChange(control, oldValue, newValue, isLoading) {
g_form.getReference('<reference_field_1>', populateValue); // doAlert is our callback function
}
function populateValue(reference_field_1) { // reference is passed into callback as first arguments
g_form.setValue('<field_name>', reference_field_1.getValue('<reference_field_2>'));
}
Let me know if it works for you.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 10:38 PM
@Tai Vu
Thank you for your advise.
I was able to execute it successfully.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 06:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 10:42 PM