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-11-2015 11:03 PM
Hi Jwalton,
This line g_form.setValue('opened for', parentRecord.opened_for); should be g_form.setValue('opened_for', parentRecord.opened_for);
Basically I can see the column name of the field opened for has blank space in it. Make sure the column name of the field is correct.
Please let me know if you have any questions.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2015 11:48 PM
Hi jwalton,
I guess 'opened_for' field in 'parentRecord.opened_for' is not an OOB field. If it is a custom field then please check the field name as it should have 'u_' prefixed to it (replace 'opened for' and 'opened_for' with 'u_opened_for' in your code). And after this as mentioned by Pradeep you should use field names and not the field labels your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2015 08:14 AM
Pradeep Sharma, thanks for spotting that typo. I have corrected it:
g_form.setValue('opened_for', parentRecord.opened_for);
However, i am still not returning the value from the parent based on my log output.
Tanaji Patil, this is an OOB field from the 'Facilities Request' table: here is the dictionary entry:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2015 08:32 AM
Hello, could it be that the opened_for is not set in the parent (FCR0010085)?
Thanks,
Berny