How to get field value of reference filed value.

Tippireddy Venk
Tera Contributor

I'm writing client script for Ctask. In which I want field value of planed date of change request  which is  reference field of Ctask. can any one please give the syntax for this.

I have tried.

g_form.getValue('change_request.planed_date');

which is not working.

3 REPLIES 3

SA25
Tera Contributor

var ctask = g_form.getValue('field_name');

The value of that field will be collected into the ctask variable and you can use it anywhere in script.

Tai Vu
Kilo Patron
Kilo Patron

Hi @Tippireddy Venk 

To get the planned_date from the Change Request reference field on the catalog task [sc_task] form, you can use GlideAjax or the getReference(String fieldName, Function callBack) API.

Sample below.

function onChange(control, oldValue, newValue, isLoading) {
    g_form.getReference('change_request', callback); //callback function
}
 
function callback(grChange) { // reference is passed into callback as first arguments
   alert(grChange.getValue('planned_date'));
   //todo
}

 

Cheers,

Tai Vu

Ankur Bawiskar
Tera Patron
Tera Patron

@Tippireddy Venk 

you should use getReference with callback to get the value or use GlideAjax

what did you start with and where are you stuck?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader