Auto populate user details

Shabbir1
Tera Contributor

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

1 ACCEPTED SOLUTION

Vrushali  Kolte
Mega Sage

Hello @Shabbir1 ,

 

You can create onChange client script on requested_for variable as below -

 

VrushaliKolte_0-1720499537681.png

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.

View solution in original post

5 REPLIES 5

Community Alums
Not applicable

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);
}
});
}