- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 10:25 AM
On my form I have a field that shows the requester's email address when the form loads:
in order to get this done , on the default value of the filed i have :
Now , on the form, if someone selects yes in (Is this on behalf of someone else?) , in the ( on behalf of) they can select another user. so if this happens , i need the user's email address pop up in another field. what is the easiest way to achieve this?
Solved! Go to Solution.
- 8,252 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 11:09 AM
function onChange(control, oldValue, newValue, isLoading) {
alert("Value of on_behalf_ref is: "+ on_behalf_ref);
var usr= g_form.getReference('on_behalf_ref', doAlert);
}
function doAlert(usr) {
if (usr.email != '')
alert("email is: " + usr.email);
g_form.setValue('requested_for', usr.email);
}
Can you try this, and tell me what are the alert messages (there should be 2 messages).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 10:29 AM
Write a on change client script.
Use getReference() function there to get user's email.
Please follow below link for your reference.
GlideForm (g form) - ServiceNow Wiki
Thanks,
Mihir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 10:47 AM
var usr=g_form.getReference('on_behalf_ref',doAlert);
function doAlert(usr) { //reference is passed into callback as first arguments
g_form.setValue('requested_for', usr.email);
}
doesn't work!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 10:58 AM
Hi Soni,
Try this -
function onChange(control, oldValue, newValue, isLoading) {
var usr= g_form.getReference('on_behalf_ref', doAlert);
}
function doAlert(usr) {
if (usr != '')
alert("email is: " + usr.email);
g_form.setValue('requested_for', usr.email);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2016 11:14 AM
Another problem with this client script that I have is that even if the field (Is this on behalf of someone else?) is selected as No , the on behalf of field is shown. But the On behalf of the field should only be visible when yes is selected. but when i wrote the client script those fields are visible but they shouldn't.
and the functionality is not working either