The button should be able to show the popup with phone number of the incident's caller

nivethika
Tera Contributor

Hi Team,

 

I have a requirement that there should be one button in Service Operation Workspace - incident form. When the user clicks the button there should be popup with caller's phone number. It should be clickable. 

 

Any help would be appreciated & helpful.

 

Thanks in Advance,

Nivethika

1 ACCEPTED SOLUTION

hi @nivethika 

Try bellow:

- create a new UI Action.

- Fill in the following fields:

 

  • Name: Call
  • Table: Incident [incident]
  • Condition: current.caller_id.isValid() (ensures the caller is set)
  • Action name: show_caller_phone
  • Show in list: false
  • Show in form: true
  • Client: true

 

function showCallerPhone() {
    var callerPhone = current.caller_id.phone; // Fetch the caller's phone number
    if (callerPhone) {
        var html = '<a href="tel:' + callerPhone + '">' + callerPhone + '</a>';
        var dialog = new GlideModal('Caller Phone');
        dialog.setBody(html, false);
        dialog.setTitle('Caller Phone Number');
        dialog.render();
    } else {
        alert("No phone number found for the caller.");
    }
}

// Call the function when the button is clicked
showCallerPhone();

 

 

View solution in original post

10 REPLIES 10

Brian Lancaster
Tera Sage

This already exists. There is a field info icon in the caller field that will open the record in a new tab. Why reinvent the wheel.

BrianLancaster_0-1727188694362.png

 

Rajesh Chopade1
Mega Sage

Hi @nivethika 

What @Brian Lancaster suggested is OOB and recommended, but if you having specific requirement then you can achieve this by using UI Action.

 

- Set the Condition to show the button only in specific contexts, such as when the user is in the Workspace or based on the incident state. You can check for workspace-specific roles.

- Providing bellow sample script, do required changes as per your requirement:

// Open a modal dialog showing the caller's phone number
function showPhoneNumber() {
    var callerPhone = g_form.getValue('caller_id.phone'); // Get the phone number from the caller field
    if (callerPhone) {
        // Use a modal dialog to display the phone number
        var dialog = new GlideDialogWindow('glide_confirm_basic');
        dialog.setTitle('Caller Phone Number');
        dialog.setPreference('title', 'Caller Phone Number');
        dialog.setPreference('question', '<a href="tel:' + callerPhone + '">' + callerPhone + '</a>'); // Clickable phone number
        dialog.setPreference('button_label', 'Close');
        dialog.render();
    } else {
        alert('No phone number available for the caller.');
    }
}

 

i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

rajesh

Thank you so much @Rajesh Chopade1  for sharing the information.

 

I tried with this code but it is not working. Please help me to achieve it. Below attached my screen shot for your reference.

hi @nivethika 

please do following changes 

 

  • Show Insert: False
  • Show Update: False

and make sure caller's phone number is not blank in user table.