Client script doesn't work as it should
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2025 11:44 AM
I have two reference fields, but one will be hidden and the other will be visible. When the visible field is filled in, it should automatically fill in the other with the same information. To do this, I created a client script, but it doesn't work. Could someone help me?
function onSubmit() {
var categoria = '00000022_categoria';
g_form.setValue('kb_category', categoria);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2025 11:47 AM - edited 02-21-2025 11:52 AM
Hi,
Can you please try using onLoad() or onChange ().
onSubmit () is not the correct event to set a field value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2025 12:02 PM
Hi @Ariomar de Deus ,
If both are reference type, means pointing to some source table, and second one dependent upon first one means there is some common column ( relation ) exist.
Did you try the auto-populate option on second reference field.
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2025 12:03 PM
it should automatically fill in the other with the same information.
This is a strange requirement. Can you expand on why you need to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2025 12:14 PM - edited 02-25-2025 07:38 PM
Few things for you:
- What do you mean by "but it doesn't work"?
- I'm guessing that is not the true Client Script as you are hard-coding the "categoria" variable.
- when setting the value of a Reference field, you need to use a sys_id of the referenced record
- is that for a normal form or a catalog item?
- why are you doing this? What is the real requirement?