- 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-18-2020 12:43 AM
Hi,
try below to set display value
var res = source_table_gr.sys_id.toString();
gr.cmdb_reference_field.setDisplayValue(res);
Thanks,
Kunal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2020 12:50 AM
Hi,
Will that be a valid scenario that name of cmdb_ci record would be empty?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2020 01:17 AM
It is a case of bad CMDB, but ServiceNow does not restrict creating records with empty Name, so we need to handle it specifically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2020 01:47 AM
Hi Nancy,
ideally there should be only 1 column with display=true
Is this issue resolved or still help is required?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
