- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2020 11:02 PM
Hello folks,
I have developed an integration where I need to relate my records to the cmdb_ci table, for that, I have added the reference field to my table referencing the cmdb_ci. I populate the value in the reference field from my code where I add the sys_id of the cmdb_ci record to my reference type field and when I view the record in form view I get the "name" of cmdb_ci record in the field type. For eg.
Now I faced and issue when the "name" field of the cmdb_ci record did not have any value ie it was empty. Even if I get the correct sys_id in my code and it is assigned to this field, when I go to the form view I find that the value is empty. I also tried to assign the value manually when the name was empty but found no luck.
I know that we can change the display value for a table and then that value is shown in referenced field. But I do not want the user to do that configuration manually ie I want the solution to be part of my application code.
Does anyone know the reason if the name field or the field marked as displayvalue=true is empty then why does it not allow to add the refernce value. And if so what would be the workaround.
Thanks,
Nancy
Solved! Go to Solution.
- Labels:
-
Integrations
-
Multiple Versions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2020 11:56 PM
Hi,
Try below code
var gr = new GlideRecord('target_table');
gr.initialize()
.
Inserting other fields
.
.
gr.cmdb_reference_field = source_table_gr.sys_id.toString(); // getting this from ablove
gr.insert();
Thanks,
Kunal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2020 11:13 PM
Hi Nancy,
You must be using advanced reference qualifier where you're passing sys_id's which you get from script include function.
Do you mind can you share the script include code ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2020 11:21 PM
The code is like:
var gr = new GlideRecord('target_table');
gr.initialize()
.
Inserting other fields
.
.
gr.cmdb_reference_field = source_table_gr.sys_id; // getting this from ablove
gr.insert();
And I am not using any advance reference qualifier functionality

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2020 11:56 PM
Hi,
Try below code
var gr = new GlideRecord('target_table');
gr.initialize()
.
Inserting other fields
.
.
gr.cmdb_reference_field = source_table_gr.sys_id.toString(); // getting this from ablove
gr.insert();
Thanks,
Kunal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2020 12:24 AM
Kunal thanks for your response, it worked!
But still the value is empty, because the name is empty. I can see the info icon which allows me to go to the parent record. Is there a way where we can change the display value of a table from code i.e fix the column to be used in display for reference field?