- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2024 09:58 PM
Hi Team,
How to load data on the configuration item custom fields like abc(high),xyz(low),hds(medium) which are choice field
based on class(choice), family(choice) and department (reference) which is not unique
Thanks & Regards,
Ramu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2024 12:02 AM
Hi @Ramu8 ,
You can do the following.
- Create a table in ServiceNow to store mappings of class, family, department, and the corresponding values for the choice field.
- Create an onInsert or onUpdate Business Rule for the CI table and use a script to fetch the appropriate values from the mapping table based on the class, family, and department.
- Populate the custom fields dynamically.
Use below code in business rule.
var mapping = new GlideRecord('your_mapping_table');
mapping.addQuery('class', current.class);
mapping.addQuery('family', current.family);
mapping.addQuery('department', current.department);
mapping.query();
if (mapping.next()) {
current.abc = mapping.abc_value; // Replace with actual field names
current.xyz = mapping.xyz_value;
current.hds = mapping.hds_value;
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2024 12:02 AM
Hi @Ramu8 ,
You can do the following.
- Create a table in ServiceNow to store mappings of class, family, department, and the corresponding values for the choice field.
- Create an onInsert or onUpdate Business Rule for the CI table and use a script to fetch the appropriate values from the mapping table based on the class, family, and department.
- Populate the custom fields dynamically.
Use below code in business rule.
var mapping = new GlideRecord('your_mapping_table');
mapping.addQuery('class', current.class);
mapping.addQuery('family', current.family);
mapping.addQuery('department', current.department);
mapping.query();
if (mapping.next()) {
current.abc = mapping.abc_value; // Replace with actual field names
current.xyz = mapping.xyz_value;
current.hds = mapping.hds_value;
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2024 04:26 AM
added current.update(); line
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 01:50 AM
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark