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

Ok..Got it...Your Supervisor field should be a reference. Looks like you have set it as Lookup Select Box


Please mark this response as correct or helpful if it assisted you with your question.

My supervisor name field ('bulkmail_supervisor_name') is a reference field. 

 

find_real_file.png

Ok..Lets do this

 




function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

var rec = new GlideRecord('sys_user');
rec.addQuery('sys_id',g_form.getValue('bulkmail_supervisor_name'));

rec.query(recResponse);

function recResponse(rec)

{

if (rec.next()) { g_form.setValue('bulkmail_supervisor_phone',rec.phone);
}
}
}

 

Please mark this response as correct or helpful if it assisted you with your question.

Sanjiv, It's really confusing to have you always jumping in on threads like this.  I've already suggested this exact thing 3 separate times but people can't quickly identify that response because you're muddying the waters.  If someone else is already answering a question you need to back off until it's clear that they need your help.  I appreciate that you're trying to help answer questions, but hijacking threads like this just isn't helping.

Mark, I don't think I am hijacking any of your threads. I am replying If I have an alternate solution. I can't wait for someone to respond . And if someone is already answering, it doesn't mean I can't put my points. 

I will give you an example of what I am doing and may be you are not realizing when you are doing it,

https://community.servicenow.com/community?id=community_question&sys_id=04b2fce9db0823c0200f0b55ca96...


Please mark this response as correct or helpful if it assisted you with your question.