g_form.getReference returns an undefined value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2015 10:59 PM
I am currently trying to create a child ticket with all the information from the parent in it.
Using the new button on the related list 'Facilities Request->Parent';
the following client script is triggered:
function onLoad() {
if(g_form.isNewRecord()){
var dad = g_form.getValue('parent');
if(dad != ''){
var parentRecord = g_form.getReference('parent');
g_form.setValue('opened for', parentRecord.opened_for);
g_form.setValue('location', parentRecord.location);
jslog("JW-DEBUG: " + parentRecord.opened_for);
jslog("JW-DEBUG: " + parentRecord.location);
}
}
}
function onLoad() {
if(g_form.isNewRecord()){
var dad = g_form.getValue('parent');
if(dad != ''){
var parentRecord = g_form.getReference('parent');
g_form.setValue('opened for', parentRecord.opened_for)
The location field is correctly populated on my child ticket, however, the opened_for is not.
Looking at the javascript log i see the following:
JW-DEBUG: undefined
JW-DEBUG: b466f2800a0a3c7e00b84e0d16c206ae
Both fields are reference fields so I am confused why one works and one does not - any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2015 10:13 AM
Yes, opened_for is set on the parent record. It is a required field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2015 12:44 AM
Hi Jwalton,
Can you check if the column name of the parent field is "parent". Also try to keep the alert statements in client script and check which line is exactly causing the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2015 10:18 AM
No sure I follow. The column name of the parent field is 'opened_for', and which alerts are you referring to?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2015 10:34 AM
Jwalton,
To get request_for value below is the working code that I have.
Please replace with opened_for and try if it works.
var reqByName = g_form.getReference('requested_by');
if (reqByName != ''){
g_form.setValue('requested_by_id',reqByName.user_name);}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2015 10:47 AM
I updated the client script with your code:
function onLoad() {
if(g_form.isNewRecord()){
var dad = g_form.getValue('parent');
if(dad != ''){
var parentRecord = g_form.getReference('parent');
g_form.setValue('opened_for', parentRecord.opened_for);
g_form.setValue('location', parentRecord.location);
var reqByName = g_form.getReference('opened_for');
if (reqByName != ''){
g_form.setValue('requested_by_id',reqByName.user_name);
}
jslog("JW-DEBUG: " + parentRecord.opened_for);
jslog("JW-DEBUG: " + parentRecord.location);
jslog("JW-DEBUG: " + reqByName);
}
}
}
JS debug returned the following:
JW-DEBUG: undefined
JW-DEBUG: c5b48cbb0a0a3c7e01a3328fd5bb601a
JW-DEBUG: [object Object]