Classify Configuration Item (CI)

Alan Carvalho
Tera Contributor

Hello community,

I am creating a process to automatically classify the configuration item (CI) registered in my CMDB from points assigned based on some fields available in the CI itself register.

 

To do this, create a field named Sort Type List that contains values such as: 1 - Gold, ,2 - Silver, 3 - Bronze, and so on.

 

I also created four new fields in the IC register that contain the YES and NO options for selection, where each of these fields has a score when the YES option is selected.

 

Based on the sum of the four grades, the CI will be classified through the Classification field.

 

For this process I created the following business rule that is not working because the value of the rating field does not change based on the score.

This is the configuration for the execution of the rule.

AlanCarvalho_0-1731088741907.png

 

This is the watering script.

(function(current) {

    // Define as notas para cada campo de escolha
    var notaExpostoInternet = 30;
    var notaAltaDisponibilidade = 30;
    var notaDadosFinanceiros = 20;
    var notaRegulatorio = 20;

    // Calcula a nota total
    var notaTotal = 0;
    if (current.u_exposto_para_internet == 'Sim') {
        notaTotal += notaExpostoInternet;
    }
    if (current.u_possui_alta_disponibilidade == 'Sim') {
        notaTotal += notaAltaDisponibilidade;
    }
    if (current.u_trafega_e_ou_armazena_dados_financeiros == 'Sim') {
        notaTotal += notaDadosFinanceiros;
    }
    if (current.u_atende_algum_regulatorio_e_ou_norma == 'Sim') {
        notaTotal += notaRegulatorio;
    }

    // Classifica o IC com base na nota total
    var classificacao = '';
    if (notaTotal >= 80) {
        classificacao = '1 - Ouro';
    } else if (notaTotal >= 50) {
        classificacao = '2 - Diamante';
    } else {
        classificacao = '3 - Platina';
    }

    // Atribui a classificação a um campo no registro
    current.u_classificacao = classificacao;

})(current);
 

 

Could you help me solve this problem?

2 REPLIES 2

Runjay Patel
Giga Sage

Hi @Alan Carvalho ,

 

Script look fine, i tested in background script. check two things.

  1.   classificacao = '1 - Ouro'; choice value of "u_classificacao", might have different value or instead of value you are setting label.
  2. RunjayPatel_0-1731132607164.png

     

  3.  fild name for "u_classificacao", might have different name.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

Hi @Runjay Patel 

 

The field that I need to fill in when registering my IC is called u_classificacao.

AlanCarvalho_0-1731438092884.png

 

The classification value in the script was defining a label instead of a value, I changed it to the value but the business rule still doesn't work.

These are the options in the u_classificacao field.

AlanCarvalho_1-1731438372866.png

What else could be wrong?