Json value change
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-06-2024 06:34 PM
Can someone help here
Their is a field "source data" in the discovered tem table which contains "assessed _for_Vulnerabilites" :false in JSON value need to replace it with assessed _for_Vulnerabilites" :true
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-06-2024 07:32 PM
@Mahesh137 You can use following script as a reference point to update an attribute in a JSON field.
var glideIRE = new GlideRecord('cmdb_ire_output_target_item'); //add your table na,e here
glideIRE.query();
//glideIRE.addQuery(); add your filters here
if(glideIRE.next())
{
var jsonVal = JSON.parse(glideIRE.getValue('source_data')); //
//gs.print(jsonVal.);
if(jsonVal['Assessed for Vulnerabilities']){
var assess=jsonVal['Assessed for Vulnerabilities'];
if(assess=='false'){
jsonVal['Assessed for Vulnerabilities']='true';
glideIRE.setValue('source_data',JSON.stringify(jsonVal));
glideIRE.update();
}
}
}
Hope this helps.