- 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:07 AM
Looks like you're missing a closing bracket. Can you try this?
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 09:18 AM
I added the missing a closing bracket. But, still not working. I am not sure gerReference work in portal.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2018 09:24 AM
It should work. I assume 'bulkmail_supervisor_name' is a reference field referencing the 'sys_user' table? What do you see if you add some alerts in like this?
function onLoad() {
alert('Running');
//Type appropriate comment here, and begin script below
var supervisorRef = g_form.getReference('bulkmail_supervisor_name', popSupervisorInfo);
}
function popSupervisorInfo(supervisorRef) {
alert('Hit callback ' + supervisorRef.name);
if (supervisorRef.phone) {
alert('Found 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:32 AM
Maybe 'getReference' doesn't work in the portal. You can use GlideRecord instead.
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()) {
if (supervisorRef.phone) {
g_form.setValue('bulkmail_supervisor_phone', supervisorRef.phone);
}
}
}