
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2020 11:29 AM
Hello,
How do I get the value of a field not shown on the current form from within a client script? I'm trying to get the value of incident.child_incidents from a client script for incident.
I've tried "g_form.getValue('child_incidents')" but it returns undefined unless I pull the field onto the form. However, I do not want this field on the form. If I remove the field, it goes back to returning undefined. How do I get around this?
Thanks!
Kind Regards,
Joseph
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2020 12:00 PM
A few choices here:
- Put the field on the form and hide with a UI Policy.
- Retrieve it via a GlideAJAX call
- Use a Display Business Rule to put the field value on the scratchpad for use
There may be other methods, but these are the 3 that come to mind.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2020 12:00 PM
A few choices here:
- Put the field on the form and hide with a UI Policy.
- Retrieve it via a GlideAJAX call
- Use a Display Business Rule to put the field value on the scratchpad for use
There may be other methods, but these are the 3 that come to mind.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2020 12:02 PM
Thanks Matthew! That's great, could you give me a working example of GlideAJAX please? I'm having a bit of difficulty with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2020 12:26 PM
In it's most basic form, this will return the sys_created_on field for an incident
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('glideAJAXCall'); //must match the name of the script include
ga.addParam('sysparm_name', 'getFieldValue'); //must match the name of the function
ga.addParam('sysparm_sys_id', g_form.getUniqueValue()); //passing in incident sys_id
ga.getXMLAnswer(responseToParse); //function name from below
function responseToParse(response) {
//var answer = response;
alert(response);
}
}
Script Include:
Name: glideAJAXCall
Client Callable: true
var glideAJAXCall = Class.create();
glideAJAXCall.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getFieldValue: function(){
var sysid = this.getParameter("sysparm_sys_id");
var gr = new GlideRecord("incident");
gr.get(sysid);
return gr.sys_created_on;
},
type: 'glideAJAXCall'
});
Again, this is in its most basic form, but putting this in should popup the sys_created_on value for the incident. From there, you can do with that value whatever you want.
If you need some more assistance, you may need to provide a few more details on what table/field you're working with.
Happy to help further if need be.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 01:03 PM
Thanks Mathew, can you help me to set value ? I tweaked your code and i got the alert message that it successfully set the value but when i see it in list view I don't see the value got actually updated.