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:15 PM
setValue doesnt work this way,
Try using:
dependencyGR.setValue("impact_analysis",current.impact_analysis);
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 11:29 PM
Thank you. Not working either.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 11:17 PM
print log here gs.info("Impact analysis value".+ current.getValue('impact_analysis'));//check whether value is printing?
dependencyGR.impact_analysis.setDisplayValue('impact_analysis');
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2022 11:23 PM
Hi
As you have already mentioned that imapct_analysis in Table 1 is of type reference and current.impact_analysis also belong to the same table (Table 1) which should also be of type reference. If that is the case then you need not use:
dependencyGR.impact_analysis.setDisplayValue( current.impact_analysis);
instead, you can go for:
dependencyGR.setValue('impact_analysis', current.impact_analysis);
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik