Auto Assign Asset from created field on sctask form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2024 12:44 PM
I've added a field to the 'sctask' form that references the 'cmdb_ci_computer' table. Within this field, I've enabled the display of asset serial numbers to facilitate searching for specific assets by their serial numbers. The objective is to automate the assignment of the selected asset, identified by its serial number, to the 'requested for' field on the same 'sctask' form. How to achieve that? I've tried client script, but sounds like I'm doing something wrong! or applying the wrong tables here. One thing to know that my assets has been loaded manually to two tables, cmdb_ci_computer and alm_hardware, and I've applied this fix script to connect both :
var assetGR = new GlideRecord("alm_hardware");
assetGR.addEncodedQuery('ciISNOTEMPTY');
assetGR.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
assetGR.query();
while (assetGR.next()) {
var gr = new GlideRecord("cmdb_ci_computer");
gr.addQuery("serial_number", assetGR.serial_number);
gr.query();
if (gr.next()) {
gr.asset = assetGR.sys_id
gr.update();
//gs.info(gr.name + ' - ' + assetGR.sys_id);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2024 02:51 PM
alm_hardware record is Asset
computer table record is called CI
if you update the asset record. it will auto update the CI