How to fetch particular variable details in reference field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 12:22 AM
Hi,
I need to create a reference field on "cmdb_ci_cloud_service_account" named : "Product Category".
Product category is going to be reference of "spm_taxonomy_node" table.
The reference field populates with the name of the record, but I have a custom request that "description"(one of the attributes of the referenced record) should be populated in the reference field, rather than the record name.
example:
Here is the form view of "cmdb_ci_cloud_service_account" table where "Product category" is created.
Here is the same referenced record from "spm_taxonomy_node".
Current behaviour : In reference field we get the names ie.. "name" attribute.
Required behaviour: I need the description ie.. "description"(one of the attributes of the referenced record) attribute, in the reference variable in "Product category" field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 12:35 AM
Hi @Hrishabh Kumar ,
Navigate to the table configuration of the "spm_taxonomy_node" table, and under columns - set display to 'true' for description
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 01:40 AM
Hey I tried the same solution but it is not working, I can still see names in the reference list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 01:54 AM
I need the description to be shown in the reference variable list.
Right now if I click on the search icon near the reference variable, it opens the list with name attribute, I need it to have Description attribute also.
Weather we have description field only, or description field along with name field. Both will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2023 02:13 AM
Hi @Hrishabh Kumar ,
Hope you are doing great.
To achieve the desired behavior of populating the "description" attribute instead of the record name in the "Product Category" reference field on the "cmdb_ci_cloud_service_account" table, you can follow these steps:
Go to the "cmdb_ci_cloud_service_account" table definition.
Add a new reference field named "Product Category" to the "cmdb_ci_cloud_service_account" table.
Set the reference table of the "Product Category" field to "spm_taxonomy_node".
Modify the dictionary attribute of the "Product Category" field to use the "description" attribute of the referenced record instead of the default "name" attribute.
Here's an example of how the code snippet would look like in ServiceNow:
// Step 1: Navigate to "cmdb_ci_cloud_service_account" table definition
// and add a new reference field.
// Step 2: Modify the "Product Category" reference field properties.
var productCategoryField = new GlideRecord('sys_dictionary');
if (productCategoryField.get('name', 'cmdb_ci_cloud_service_account.product_category')) {
productCategoryField.reference = 'spm_taxonomy_node';
productCategoryField.reference_qual = '';
productCategoryField.reference_key = 'description';
productCategoryField.update();
}
Regards,
Riya Verma