- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 08:15 AM
Hi, Following unload script is not working on new Portal. I tried to use GlidAjex and realized GlideAjex is not supporting portal too. does getRefrence also not support portal??
function onLoad() {
//Type appropriate comment here, and begin script below
var supervisorRef = g_form.getReference('bulkmail_supervisor_name', popSupervisorInfo);
function popSupervisorInfo(supervisorRef) {
if (supervisorRef.phone) {
g_form.setValue('bulkmail_supervisor_phone', supervisorRef.phone);
}
}
Thank you!
Dilini
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 10:51 AM
If you run this do you see an alert with the supervisor name?
function onLoad() {
// Query for the supervisor
var supervisorRef = new GlideRecord('sys_user');
supervisorRef.addQuery('sys_id', g_form.getValue('bulkmail_supervisor_name'));
supervisorRef.query(popSupervisorInfo);
}
function popSupervisorInfo(supervisorRef) {
if (supervisorRef.next()) {
alert('Supervisor: ' + supervisorRef.name);
if (supervisorRef.phone) {
g_form.setValue('bulkmail_supervisor_phone', supervisorRef.phone);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 09:44 AM
Hi Mark,
above code doesn't work too.
YES, 'bulkmail_supervisor_name' is reference in a catalog item and field referring 'sys_user' table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 09:55 AM
Try changing it to an 'onChange' script on the 'bulkmail_supervisor_name' field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 10:13 AM
onChance doesn't work too.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
supervisorPhone = g_form.getReference('bulkmail_supervisor_name', populate_phone);
}
function populate_phone(supervisorPhone) {
if (supervisorPhone.phone) {
g_form.setValue('bulkmail_supervisor_phone', supervisorPhone.phone);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 10:20 AM
Hi Dilini,
g_form.getReference with callback should work fine in portal as well.
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 10:32 AM
Can you add some alerts and try
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert('manager sys_id '+g_form.getValue('bulkmail_supervisor_name'));
//Type appropriate comment here, and begin script below
supervisorPhone = g_form.getReference('bulkmail_supervisor_name', populate_phone);
}
function populate_phone(supervisorPhone) {
alert('manager phone '+supervisorPhone.phone);
if (supervisorPhone.phone) {
g_form.setValue('bulkmail_supervisor_phone', supervisorPhone.phone);
}
}
Please mark this response as correct or helpful if it assisted you with your question.