'Script servicenow

for each "grdmnImpactsSistemi" I have to sum its value, knowing that its value is "u_stima_economica" how do I sum it and put it inside the variable "var sumImpattoSistemi = 0"

var grdmn = new GlideRecord("dmn_demand");

grdmn.addEncodedQuery("state!=9^state!=1^state!=11");


grdmn.query();

while(grdmn.next()){
   var grdmnImpactsSistemi = new GlideRecord("u_m2m_impatto_sistemi");
   grdmnImpactsSistemi.addQuery("u_project_demand", grdmn.getUniqueValue());
   grdmnImpactsSistemi.query();
   var sumImpactsSistemi = 0;

  
  while(grdmnImpactsSistemi.next()){
  //for each impact I have to sum its value "u_stima_economica"
}
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source