How to get field value of reference filed value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 12:58 AM - edited 12-01-2023 12:59 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 01:24 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 01:33 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 01:36 AM
you should use getReference with callback to get the value or use GlideAjax
what did you start with and where are you stuck?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader