- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2020 05:20 AM
Unable to retrieve the value which is being passed from server script
Server script:-
data.name = '';
data.email = '';
// get current user email
var uemail;
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id', gs.getUserID());
usr.query();
if(usr.next())
{
data.email = usr.email;
}
client script:-
var temp = c.data.email;
alert(JSON.stringify(c.data.email));
Alert returns empty { }
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2020 05:46 AM
Assumption - you are using Service Portal. If this is standard lists/forms, please clarify. The approach is totally different.
Note: Always assume (because it's true) that fields are objects. If you want the value, use getValue() or getDisplayValue().
Server script:
data.email = '';
var usr = new GlideRecord('sys_user');
if (usr.get(gs.getUserID()) {
data.email = usr.getValue('email');
if (data.email == '') {
gs.error('This user has no email');
}
} else {
gs.error('Unable to read current user record');
}
Client script:
console.log('Email=' + c.data.email);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2020 05:36 AM
im using the piece of code in widget server and client

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2020 05:46 AM
try
Server script:-
data.name = '';
data.email = '';
// get current user email
var uemail;
var usr = new GlideRecord('sys_user');
if(usr.get(gs.getUserID())){
data.email = usr.email.toString();
}
client script:-
var temp = c.data.email;
alert(temp);