
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 09:46 PM
For a catalog item I'm creating I need to populate a reference field if checkbox is checked, with the current user.
Checkbox variable field:
checkbox_1
Reference field on sys_user table:
name_field
If checkbox_1 = true then name_field = current users name
I figure this would require a Catalog Client Script?
Not sure how to write it - if anyone is able to assist please?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 10:23 PM
Ok thank you @Anirudh Pathak I've tried it and hasn't worked unfortunately
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var check = g_form.getValue('checkbox_1');
if (check == true) {
g_form.setValue('name_field', g_user.userID);
} else {
g_form.clearValue('name_field');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 10:25 PM
Hi @Bidduam ,
Can you update your code to the below one -
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == 'true') {
g_form.setValue('name_field', g_user.userID);
} else {
g_form.clearValue('name_field');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 10:28 PM
@Anirudh Pathak that worked perfectly thank you 😀
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 10:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 10:28 PM
Hello @Bidduam ,
You need to create on change client script for checkbox variable and write the script as follows :
Note: Please replace the variable name as per your case.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue == 'true' || newValue == true){
var user = g_user.userID; //get current user ID
alert('user '+ user);
g_form.setValue('assigned_to',user); // replace assigned_to with actual variable name
}
//Type appropriate comment here, and begin script below
}
Please mark my answer as Accepted ✔️ and Helpful 👍 based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 10:35 PM
Hi @Bidduam ,
Write a on change client script on checkbox field and write below code in a script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue=='true')
{
g_form.setValue('field_value',g_user.userID);
}
else
{
g_form.clearValue('field_value');
}
}
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Ranjit