Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Unable to display caller name in SOW

vidhya_mouli
Tera Sage

A pop up window should appear with a message when the Channel changes. I need to display the caller name. This code works but it does not display the caller name. This is a client script and the agent is on Service operational workspace.

 

 

 

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

	var previousChannelType = oldValue;
	var callerID = g_form.getValue('caller_id');
	var caller = "";

	//Get the name of the caller
	if (callerID) {
    	var userRecord = new GlideRecord('sys_user');
    	if (userRecord.get(callerID)) {
        	var firstName = userRecord.getValue('first_name');
			var lastName = userRecord.getValue('last_name');
        	caller = firstName + " " + lastName;
    	}
	}

	
			
   // Check if the selected channel type is 'alert / notification'
   if (previousChannelType != '' && previousChannelType != 'alarm_notification' ) {

	var msg = "Please note : This incident is currently defined as " +  previousChannelType + " channel type and has been changed to alert/notification channel type. The caller " + caller + " has been removed from the incident.";

	g_form.addInfoMessage("previousChannelType: " + previousChannelType);
	
	g_modal.confirm(getMessage("Alert"), msg, function (confirmed) {
		if (confirmed) {
			g_form.save();
		}
	});

		return false;
  }

  
	
}

 

 

 

1 ACCEPTED SOLUTION

Danish Bhairag2
Tera Sage

Hi @vidhya_mouli ,

 

Its not recommended to use GlideRecord in Client Script kindly call a script include using GlideAjax to retrieve caller id name .

 

Thanks,

Danish

 

View solution in original post

1 REPLY 1

Danish Bhairag2
Tera Sage

Hi @vidhya_mouli ,

 

Its not recommended to use GlideRecord in Client Script kindly call a script include using GlideAjax to retrieve caller id name .

 

Thanks,

Danish