- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 10:19 AM
I need to reference a parent field on a child client script.
It is not working.
var category = g_form.getValue('x_table_name.parent_case.field_name');
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 11:04 AM
Have you tried a "getReference" script function yet?
I recently used the following script in an onChange Client Script for when the Category field is changed and it then checks values on the Category record. Actually this one runs two separate getReference lookups on two different tables.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue && g_form.getValue('proposal_type', 2)) {
checkIfEpic();
}
function checkIfEpic() { //* first reference lookup
g_form.getReference('category', doAlert);
}
function doAlert(getCat) {
if (getCat.getValue('parent') == '04982248db357680ec5c3c00ad961962' || getCat.getValue('parent') == '93b2fe57db55b280deda327e9d961997') {
g_form.setReadOnly('category', true);
g_form.setReadOnly('template_name', true);
getDesc();
}
}
function getDesc() { //* second reference lookup
g_form.getReference('std_change_producer', doAlert2);
}
function doAlert2(getDesc) {
g_form.setValue('short_description', getDesc.short_description);
g_form.setReadOnly('short_description', true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 10:26 AM
Not getting the statement completely!
Still let me try to answer it, if you want to get parent field in child table client script, please try:
g_form.getValue("NAME_OF_THE_FIELD_IN_PARENT_TABLE");
because that field is the part of child table also!
If it has not answered your query please take a look at THIS
If still your question is different, please explain it in little more details with screenshot 🙂
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 10:34 AM
I have tried using as you suggested above - which isn't working.
I have tried the example I put in a different script which does work but not sure why it won't work here.
I am currently looking at that other article.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 10:35 AM
Hi,
'x_table_name.parent_case.field_name' is not a form field I guess. You can use GlideAJax in the client script, along with a script include, to get the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 11:04 AM
Have you tried a "getReference" script function yet?
I recently used the following script in an onChange Client Script for when the Category field is changed and it then checks values on the Category record. Actually this one runs two separate getReference lookups on two different tables.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue && g_form.getValue('proposal_type', 2)) {
checkIfEpic();
}
function checkIfEpic() { //* first reference lookup
g_form.getReference('category', doAlert);
}
function doAlert(getCat) {
if (getCat.getValue('parent') == '04982248db357680ec5c3c00ad961962' || getCat.getValue('parent') == '93b2fe57db55b280deda327e9d961997') {
g_form.setReadOnly('category', true);
g_form.setReadOnly('template_name', true);
getDesc();
}
}
function getDesc() { //* second reference lookup
g_form.getReference('std_change_producer', doAlert2);
}
function doAlert2(getDesc) {
g_form.setValue('short_description', getDesc.short_description);
g_form.setReadOnly('short_description', true);
}
}