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

Hi @Rajesh Chopade1 

Yes i tried making false for those fields, after that button is not visible in the record. My button name is call. I checked there is phone number added in phone field as well in mobile_phone field in user table

nivethika_0-1727252823120.png

Kindly do let me know where i need to correct.

 

nivethika_0-1727268016649.png

But it is working in incident form. 

Hi @Rajesh Chopade1 ,

Thank you so much for your information.

 

I am awaiting for your further updates and instructions in this regard.

 

Thanks & Regards,

Nivethika

 

 

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();

 

 

Thanks a lot @Rajesh Chopade1 .

 

This too didn't work inside SOW incident form, 

nivethika_0-1727349098971.png

UI Action is not executing for SOW. Any specific settings have to do?

This might be having many reasons, you can have following checks:

 

Look at the browser's console for any JavaScript errors. Open the Developer Tools (usually F12) and check the Console tab. Any errors here could indicate what’s going wrong.

 

Ensure that the condition for the UI Action is correct and evaluates to true when you expect it to execute.

 

Check the roles assigned to the user attempting to execute the UI Action. Ensure that they have the necessary roles to execute it.

 

Add logs (gs.log) and check where the script is failing