Display active assigned incidents count under the 'Assigned to' filed.

Ashish Routray1
Tera Contributor

On change of "Assigned to" field, display information about active assigned incidents count of corresponding agent selected under the "Assigned to" field.

1 ACCEPTED SOLUTION

No problem. Happy to help, please mark as correct if you can.

View solution in original post

10 REPLIES 10

Instead of doing an alert if it is temporary I would use g_form.showFieldMsg('assigned_to', 'Total Assigned incident count for this user: ' + result, 'info');

Not a bad idea at all Brian. 🙂

Whenever "Assigned to' field populated with a new agent, active assigned incidents count should be displayed as a info message under the 'Assigned to' field.

Message should be cleared, if "Assigned to" field is empty.

No message should appear after updating the incident record.

Updated client script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading) {
      return;
   }

   var rec = new GlideAjax('getAssignedToCount');
  rec.addParam('sysparm_name', 'getAssignedTo');
  rec.addParam('sysparm_assignedto', newValue);
  rec.getXML(populateData);

  // When the response is back from the server
  function populateData(response) {
    var answer = response.responseXML.documentElement.getAttribute('answer');
    var result = JSON.parse(answer);
	  if(newValue != ''){
	g_form.showFieldMsg('assigned_to','This user has ' + result + ' incidents already assigned','info');
	  }else{
	 g_form.hideFieldMsg('assigned_to');
	  }
	  
  }
}

Please mark as correct answer if it fits your requirement

Thanks Dan