UI Action to delete records

Alon Grod
Tera Expert

Hi,

 

I need to create new UI action on the device form called "Remove all installed SW"
and when click on this button I need to remove all the installed software from the device.

What am I doing wrong? the UI action is on the cmdb_ci_computer table and I need to delete all installed software on this current computer.

1 ACCEPTED SOLUTION

Hey, The script is working fine for me.

in encodedQuery() instead of 'current.name' you may use the sys_id of the record. I have tried the same from background script it deleted the record. Just try with the sys_id -> software.addEncodedQuery('installed_on='+current.sys_id);

 

My background script-

 

var software = new GlideRecord('cmdb_software_instance');
software.addEncodedQuery('installed_on=b4fd7c8437201000deeabfc8bcbe5dc1');
software.query();
while(software.next()){
software.deleteRecord();
}

 

You can share the snapshot of UI action as well. I would be able to guide more but i am sure with sys_id it should work.

 

View solution in original post

3 REPLIES 3

Kartik Choudha1
Tera Guru

Hey ,

I am not able to see the attached screenshot. could you help with script and configurations which you have done to achieve this requirement.

var software = new GlideRecord('cmdb_software_instance');
software.addEncodedQuery('installed_on='+current.name);
software.query();
while(software.next()){
software.deleteRecord();
}

Hey, The script is working fine for me.

in encodedQuery() instead of 'current.name' you may use the sys_id of the record. I have tried the same from background script it deleted the record. Just try with the sys_id -> software.addEncodedQuery('installed_on='+current.sys_id);

 

My background script-

 

var software = new GlideRecord('cmdb_software_instance');
software.addEncodedQuery('installed_on=b4fd7c8437201000deeabfc8bcbe5dc1');
software.query();
while(software.next()){
software.deleteRecord();
}

 

You can share the snapshot of UI action as well. I would be able to guide more but i am sure with sys_id it should work.