Fix Script for Remove Duplicate Hardware Models Help
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 08:55 AM
Hello,
Our organization has duplicate hardware models with assets tied to both model records.
I am trying to use the How to de-duplicate hardware models - Product Knowledge remediation play. This play comes with a Fix Script that should move the assets from the bad model record to the good one. However, when I run the fix script in our Sandbox or Dev environment, I am getting this returned
*** Script: No Data for alm_asset
*** Script: No Data for cmdb_m2m_model_component
*** Script: No Data for pc_vendor_cat_item
*** Script: No Data for cmn_m2m_skill_model
[0:00:00.008] Total Time
Here is the original script
//Move CI from the bad dup model name to the good dup model
var xcorrect_model = 'sysid1'; //The desired dup model SYS ID where the CI's will be moved from xincorrect_model
var xincorrect_model = 'sysid2';//The desired dup model SYS ID where the CI's will be moved to the xcorrect_model sys id.
var xreloc_assets= [ {"table":"alm_asset","field":"model"},{"table":"cmdb_m2m_model_component","field":"parent"},{"table":"pc_vendor_cat_item","field":"model"},{"table":"cmn_m2m_skill_model","field":"model"} ];
for(var xitem=0;xitem < xreloc_assets.length; xitem++)
relocate(xreloc_assets[xitem].table,xreloc_assets[xitem].field,xcorrect_model,xincorrect_model);
function relocate(p_table,p_field,p_correct_model,p_incorrect_model) {
var xresult = false;
try {
var xgr = new GlideRecord(p_table);
xgr.addQuery(p_field,p_incorrect_model);
xgr.setWorkflow(false); //Avoiding any further processing related to the update
xgr.setAutoSysFields(false); //Avoid update timestamp modification
xgr.query();
if(xgr.getRowCount() > 0) {
gs.info('Relocating ' + p_table );
xgr.setValue(p_field,p_correct_model);
xgr.updateMultiple();
xresult = true;
} else {
gs.info('No Data for ' + p_table );
}
} catch(e) {
gs.info(e.message);
gs.info(e.stack);
}
return xresult;
}Can anyone help me understand why it's not picking up any data for that array? Any insight would be greatly appreciated.
0 REPLIES 0
