onload catalog client script g_form.getReference in Portal not working

dilini
Giga Expert

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

1 ACCEPTED SOLUTION

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);
        }
    }
}

View solution in original post

32 REPLIES 32

This script should work without issue.  Have you tried it yet?

Yes, I tried the below. That doesn't work. 

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);
        }
    }
}

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);
        }
    }
}