Getting table values via GlideRecord

MWright1
Giga Guru

Hi all,

I have a table called u_job_title with two fields.  

find_real_file.png

On my catalog item, I have a Job Title field that looks up to this table.

I have a Catalog Client Script that I would like to limit the department list based on if the selected Job Title contains "Paralegal" or "Paraprofessional" or "Law Clerk".

find_real_file.png

I have a function that returns "yes" or "no" depending on whether the job title contains those texts:

function ifParalegalOrLawClerk() {
        alert(newValue);
        var gr = new GlideRecord('u_job_title');
        gr.get(newValue);

        var jobtitle = gr.u_job_title_english;
        var paralegal = jobtitle.indexOf("Paralegal");
        var paraprof = jobtitle.indexOf("Paraprofessional");
        var clerk = jobtitle.indexOf("Law Clerk");

        var check;

        if (paralegal >= 0) {
            return 'yes';
        }

        if (paraprof >= 0) {
            return 'yes';
        }

        if (clerk >= 0) {
            return 'yes';
        }

        return 'no';
    }

This function can't seem to get the u_job_title_english value.  It returns "undefined". 

newValue is a reference field of the newly selected Job Title.

I am not sure what I am doing wrong here.  Please help.

1 ACCEPTED SOLUTION

SumanthDosapati
Mega Sage
Mega Sage

Hi @MWright ,

 

You cannot use GlideRecord in client script.

Use GlideAjax with client callable script include to get server side data.

 

Mark it as correct or helpful if it does.

Regards,
Sumanth

View solution in original post

1 REPLY 1

SumanthDosapati
Mega Sage
Mega Sage

Hi @MWright ,

 

You cannot use GlideRecord in client script.

Use GlideAjax with client callable script include to get server side data.

 

Mark it as correct or helpful if it does.

Regards,
Sumanth