UI Action to display document template in related list of Incident

Mayur Patil2
Tera Expert

Hello developers,

 

I need to create a UI Action button on form. When I clicked , it should display a list of records from Document Table(ds_document). I am not sure which is the best way to do this.

 

Can someone guide me on the recommended approach?

 

Thank you 

 

Regards,

Mayur Patil

5 REPLIES 5

J Siva
Tera Sage

Hi @Mayur Patil2 
Could you please give more info on the requirement..?
Like what should happen after diplaying the list of records? etc..
Regards,
Siva

Nilesh Pol
Tera Guru

Hi @Mayur Patil2 

Here's a recommended approach:

Step-by-Step Guide:

  1. Create a UI Action:

    • Navigate to the UI Actions module in ServiceNow.
    • Click on New to create a new UI Action.
    • Fill in the necessary fields:
      • Name: Give your UI Action a meaningful name.
      • Table: Select the table where you want the button to appear (e.g., incident).
      • Action Name: This is a unique identifier for your action.
      • Show insert: Check this if you want the button to appear on new records.
      • Show update: Check this if you want the button to appear on existing records.
      • Condition: Specify any conditions under which the button should appear.
      • Order: Determine the order of the button relative to other UI Actions.
      • Client: Check this box to make the UI Action client-callable.
  2. Client-side Script for UI Action:

    • In the Script field, write a client-side script to show or hide the related list. Below is a sample script:

function toggleRelatedList() {
var relatedListName = 'related_list_name'; // Replace with the actual related list name
var relatedList = document.getElementById(relatedListName);

if (relatedList) {
if (relatedList.style.display === 'none') {
relatedList.style.display = '';
} else {
relatedList.style.display = 'none';
}
}
}

toggleRelatedList();

M Iftikhar
Mega Sage

@Mayur Patil2 

You can create a UI Action button that calls a Script Include. The Script Include will take input from the current record, query the ds_document table, and return the results. Based on your requirement, you can either use that data to populate fields on the current record or simply display it in a message. For reference, you can look at OOTB UI Actions on the Incident table (like Create Problem or Reopen) to understand how they’re structured.

Thanks & Regards,  
Muhammad Iftikhar  
  
If my response helped, please mark it as the accepted solution so others can benefit as well. 

Ankur Bawiskar
Tera Patron
Tera Patron

@Mayur Patil2 

what did you start with and where are you stuck?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader