- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 08:49 PM
Hi Team,
We have two variables on catalog item 1.Requested for(reference to user table) 2 VIP customer(check box). Requirement is when anyone changes the name in requested for variable if that user is VIP customer we have to show VIP customer check box as true...in user table we have a field VIP customer can anyone help me in the on change client script or any other possible way
Regards
Shabbir
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 09:34 PM
Hello @Shabbir1 ,
You can create onChange client script on requested_for variable as below -
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//please replace the field names as per your use case
var userDetails = g_form.getReference('requested_for');
if (userDetails.VIPfield == 'true') {
g_form.setValue('vip_checkbox', true);
}
//Type appropriate comment here, and begin script below
}
If my answer solves your issue, please mark it as Accepted ✔️and Helpful 👍 based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 11:30 PM
You can achieve this requirement by Glide Ajax or getReference my point of view Given the nature of your requirement, g_form.getReference should be sufficient and is generally the best approach for such a task. It is more straightforward and appropriate for simple client-side operations.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
// Fetch the referenced user record
g_form.getReference('requested_for', function(userRecord) {
// Check if the user is a VIP customer
if (userRecord.vip_customer === true) {
g_form.setValue('vip_customer', true);
} else {
g_form.setValue('vip_customer', false);
}
});
}