Advance reference qualifier

BHUSHAN KEWAT
Tera Contributor

I have created a custom field, Swapped CI, with a reference to the cmdb_ci table. I want to write an advanced reference qualifier for the Swapped CI field with the following conditions:

  1. If the Configuration Item belongs to the Software class, the Swapped CI field should display only CIs from the same class.
  2. The Configuration Item's associated asset must have an Asset State of "In Stock" and an Asset Substatus of "Available."
3 REPLIES 3

Anand Kumar P
Giga Patron
Giga Patron

Hi @BHUSHAN KEWAT ,

 

Right click on the Swapped ci field click on configure dictionary like below 

IMG_6663.jpeg

 

 then in reference specification add condition like below 

 

Select user reference qualifier:simple 

reference qual condition: class is software 

for asset state click on show related fields—dotwalk from Asset—Asset fields—state 

IMG_6666.jpeg

IMG_6667.jpeg

IMG_6668.jpeg

   

 

IMG_6664.jpeg

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand 

BHUSHAN KEWAT
Tera Contributor

@Anand Kumar P 

i have write a script 

 

function reference_quilfier_for_swapped_ci() {
    var arr = [];
    var ciInfo = new GlideRecord('cmdb_ci');
    ciInfo.addQuery('sys_id', current.ci_item);
    ciInfo.query();
    if (ciInfo.next()) {
        gs.log("9 dec 2024Line no 7: " + ciInfo.getDisplayValue('name'));
        var asset = new GlideRecord('alm_asset');
        asset.addEncodedQuery('install_status=6^substatus=available');
       // asset.addQuery('sys_class_name', ciInfo.sys_class_name);
        asset.query();
    }
    while (asset.next()) {
         gs.log("9 dec 2024 finally get records : " + asset.getDisplayValue('ci'));
        arr.push(asset.sys_id.getValue());
    }
    return 'sys_idIN' + arr.toString();
 please check this script.

Hi @BHUSHAN KEWAT ,

 

If you want to show the CI's class software and Configuration Item's associated asset must have an Asset State of "In Stock" and an Asset Substates of "Available." in Swapped field you can do with condition without writing any script, as mentioned in previous post steps .

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand