
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-03-2022 09:50 AM
Hi Community!
I initialize a catalogue item variable using javascript:gs.getUser().getEmail() to get current user's email.
But if the user updates the email address, I don't get the new one.
It seems I can reproduce this using a background script:
gs.print("Current user's email "+gs.getUser().getEmail());
And following this scenario
- run the script
- it will return your email address
- change the email address in your profile
- run the script again
- it returns the same email address as in 1.1
How can I get the new email address? Client-side friendly.
Note that I have the same behaviour with another field like 'last_name'
Thank you
Philippe
Solved! Go to Solution.
- Labels:
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-03-2022 10:12 AM
Hi,
when you use gs.getUser().getEmail()) the values are set for the session and will change only when the user logs out and logs back in, that is when you will get the new email id at the time of user logging in.
Something like below will give you the accurate value always
var gr = new GlideRecord('sys_user')
gr.get(gs.getUserID());
gs.print("Current user's email "+gr.email);
You can add this in a function on script include and just call it from client script via glide ajax.
-Anurag

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-03-2022 10:04 AM
Hey,
So it doesn't happen even if you reload and the form is freshly loaded?
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-03-2022 10:12 AM
Hi Aman,
Yes, refreshing is not enough... you have to logout then login back to get the new value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-03-2022 10:22 AM
I think this has to be done by AJAX calls via script include then.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-03-2022 10:12 AM
Hi,
when you use gs.getUser().getEmail()) the values are set for the session and will change only when the user logs out and logs back in, that is when you will get the new email id at the time of user logging in.
Something like below will give you the accurate value always
var gr = new GlideRecord('sys_user')
gr.get(gs.getUserID());
gs.print("Current user's email "+gr.email);
You can add this in a function on script include and just call it from client script via glide ajax.
-Anurag