Gliderecord Insert is not working while inserting the reference field values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 11:04 PM
Hi all,
I'm facing this strange issue while using gliderecord Insert()
Scenario: I have requirement where when a record of type 'service' is inserted in table_1 , I have a business rule that inserts 1 or more records in the same table- Table_1 with type 'capability'. The code is as follows [Here the impact_analysis is the reference field. ] :
while(gr_rel.next()) {
var dependencyGR = new GlideRecord('table_1');
dependencyGR.initialize();
dependencyGR.depends_on = gr_rel.parent; //working as expected
dependencyGR.depends_on_table= 'cmdb_ci_business_capability'; //working as expected
dependencyGR.impact_analysis.setDisplayValue( current.impact_analysis); //Not working
dependencyGR.insert();
//tried dependencyGR.impact_analysis= current.impact_analysis; Not working.
//tried dependencyGR.impact_analysis= current.impact_analysis.sys_id; Not working.
//tried dependencyGR.setValue( 'impact_analysis',current.impact_analysis);
// dependencyGR.insertWithReferences(); //gave error "insertWithReferences not in scope"
}
I read that using Display value works for reference fields. Not working for us. The value in the New inserted record is BLANK. But I tested that current.impact_analysis has value , but it is not setting the value.
Can anyone please suggest a method that works for this case.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 11:28 PM
Thank you. Not working either.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 11:30 PM
Can you put a log before this line
gs.info("impact value"+current.getValue(impact_analysis)); / check if the value is coming?
dependencyGR.setValue('impact_analysis', current.impact_analysis);
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 11:33 PM
yes we are getting the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 11:36 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 11:37 PM
Try this way just to test
var x = current.getValue(impact_analysis);
dependencyGR.impact_analysis = x;
Harish