How to hide Onhold reason "Awaiting Caller" ?

Mohammad Moula
Tera Expert

hi all,

how to hide "Awaiting Caller" for the following condition
 incident with contact type "Event Monitoring", state On-Hold, contact type !==event Monitoring, category !== Event_Management and there should be no possibility to add
on the onhold reason "awaiting caller", except for incident tickets with contact type "event Monitoring",
category "Event_Management".

1 ACCEPTED SOLUTION

Hi Harish Kota,

thanks for your reply..

i got solution using ui policy conditions with run script- g_form.removeOption('hold_reason','1');

View solution in original post

8 REPLIES 8

Abhijit
Tera Expert

you can write before business rule on incident table , 

 

when to run tab select your condition as below

state is on hold 

contact type/caller is not "event Monitoring"

category is not "Event_Management"

 

Actions tab

Add message true / checked

"You cannot add on hold reason for category - event management and called event monitoring.

 

Abort true / checked

 

Mohammad Moula
Tera Expert

i don't to add message "You cannot add on hold reason for category - event management and called event monitoring".

i want to hide Awaiting Caller in on hold reason, other choices should be there in on hold reason.

Riya Verma
Kilo Sage

Hi @Mohammad Moula ,

 

Hope you are doing great.

 

Here's the solution:

  1. Navigate to "Business Rules" in ServiceNow.
  2. Create a new Business Rule with an appropriate name, such as "Hide Awaiting Caller for Event Monitoring Incidents."
  3. Set the "Applies to" field to "Incident."
  4. Add a condition to check if the incident meets the specified criteria:

 

// Condition: incident with contact type "Event Monitoring", state On-Hold,
// contact type !== "Event Monitoring", category !== "Event_Management"
current.state == 3 && current.u_contact_type == "Event Monitoring" &&
  current.category != "Event_Management"
​

 

  • In the "Advanced" tab of the Business Rule, add the following script to prevent the addition of "Awaiting Caller" on-hold reason:

 

(function executeRule(current, previous /*null when async*/) {

  var onHoldReasons = current.u_on_hold_reason.getChoices();
  var awaitingCallerIndex = onHoldReasons.indexOf("Awaiting Caller");

  // If "Awaiting Caller" is found, remove it from the on-hold reasons
  if (awaitingCallerIndex > -1) {
    onHoldReasons.splice(awaitingCallerIndex, 1);
    current.u_on_hold_reason.setChoices(onHoldReasons);
  }
})(current, previous);
​

 

 

Hi Riya Verma,

thanks for your reply.

Business rule you suggested not working, i tried the following client script but working partially

var contacttype = g_form.getValue('u_contacttype');
var category = g_form.getValue('category');
var state = g_form.getValue('state');

if(contacttype == 'Event Monitoring' && state == '3' && category != 'Event_Management')

g_form.removeOption('hold_reason','1');

else {
if(contacttype == 'Event Monitoring' && state == '3' && category == 'Event_Management')
g_form.addOption('hold_reason','1');
}

please suggest any changes to work code as required.