How to load data using transform map based on 3 choice field

Ramu8
Tera Expert

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

1 ACCEPTED SOLUTION

Runjay Patel
Giga Sage

Hi @Ramu8 ,

 

You can do the following.

  1. Create a table in ServiceNow to store mappings of class, family, department, and the corresponding values for the choice field.
  2. 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.
  3. 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

-------------------------------------------------------------------------

 

View solution in original post

3 REPLIES 3

Runjay Patel
Giga Sage

Hi @Ramu8 ,

 

You can do the following.

  1. Create a table in ServiceNow to store mappings of class, family, department, and the corresponding values for the choice field.
  2. 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.
  3. 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

-------------------------------------------------------------------------

 

added current.update(); line

 

thank you

 

Mark Manders
Mega Patron

https://www.servicenow.com/community/developer-forum/how-to-load-data-using-transform-map-based-on-3...


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark