Issue with G_user.getClientData

Sue143
Tera Expert

Hi all,

 

I am trying to hide/show a variable in the form depending on the current user location.

I am using a client script on load on an order guide.

In the user table the value "country" should refer to the value "DE" (in the table is written in capital letters.

 

This my code:

 

function onLoad() {
    
    var user = g_user.getClientData('country');
    if (user == 'de') {
        g_form.setVisible('need_sim_card', true);
        g_form.setMandatory('need_sim_card', true);
    } else {
        g_form.setVisible('need_sim_card', false);
        g_form.setMandatory('need_sim_card', false);
    }
}
 
Unfortunately this is not working and I am not sure why. Right now it is always hiding the variable even if the user is indeed from Germany.
Please, help 🙂
1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@Sue143 

unless you set the value in that session variable from server side, you cannot get the value

please check this line

var user = g_user.getClientData('country');

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader