- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 01:04 AM
Hi All,
I have a requirement where i need to add an approve and a reject button at the end of a row in the list item. Is there a way to achieve this? I am currently using the list-simple component and am not sure how to add buttons at the end of the row. Any inputs on this will be helpful.
Thanks & Regards,
Sanjay
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 02:06 AM
Dashboards are just to view the data not to take action, so it is not possible on dashboards#
2nd on portal yes, it is OOTB available on Service Portal like this
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 02:06 AM
Dashboards are just to view the data not to take action, so it is not possible on dashboards#
2nd on portal yes, it is OOTB available on Service Portal like this
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 02:19 AM
Thanks Atul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 01:38 AM
Yes, you can achieve this by creating a UI Action in ServiceNow. Here are the steps:
1. Navigate to System UI > UI Actions in ServiceNow.
2. Click on New to create a new UI Action.
3. Fill in the necessary fields:
- Name: Give a name to your UI Action.
- Table: Select the table where you want to add the buttons.
- Action name: This is automatically populated based on the name.
- List choice: Select true if you want the action to appear in the list.
- Form button: Select false as we want to add buttons in the list not on the form.
- List banner button: Select false as we want to add buttons at the end of each row not in the list banner.
- List context menu: Select false as we don't want to add the buttons in the context menu.
- Client: Select true to make it a client-side action.
- Onclick: Write a function name that will be called when the button is clicked.
- Script: Write the script that will be executed when the button is clicked.
4. Repeat the above steps to create the Reject button.
5. After creating the UI Actions, they will appear at the end of each row in the list of the selected table.
Here is a sample code for the Approve button:
javascript
function approveRecord() {
var sysId = gel('sys_uniqueValue').value;
var ga = new GlideAjax('MyScriptInclude');
ga.addParam('sysparm_name', 'approveRecord');
ga.addParam('sysparm_sys_id', sysId);
ga.getXMLAnswer(handleResponse);
}
function handleResponse(response) {
alert(response);
}
In the above code, 'MyScriptInclude' is a Script Include where 'approveRecord' function is defined which approves the record. 'sysparm_sys_id' is the sys_id of the record which is to be approved. 'handleResponse' function handles the response from the server.
Please note that you need to have the necessary permissions to create UI Actions and the script should be written in JavaScript as ServiceNow supports JavaScript.
nowKB.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 01:56 AM
Yes, you can achieve this by creating a UI Action in ServiceNow. Here are the steps:
1. Navigate to System UI > UI Actions in ServiceNow.
2. Click on New to create a new UI Action.
3. Fill in the necessary fields:
- Name: Give a name to your UI Action (e.g., "Approve" or "Reject").
- Table: Select the table where you want to add the button.
- Action name: This is automatically populated based on the name you provided.
- List choice: Select this option if you want the UI Action to appear in the list.
4. In the Script field, write the script that should be executed when the button is clicked. For example, you can change the state of a record to "Approved" or "Rejected".
5. Click on Submit to save the UI Action.
Here is a sample code for an "Approve" UI Action:
javascript
function approveRecord(current) {
current.state = 'approved';
current.update();
}
And here is a sample code for a "Reject" UI Action:
javascript
function rejectRecord(current) {
current.state = 'rejected';
current.update();
}
Please note that you need to replace 'state' with the actual field name in your table that represents the state of the record.
After creating the UI Actions, the "Approve" and "Reject" buttons will appear at the end of each row in the list view of the selected table. When a user clicks on one of these buttons, the corresponding script will be executed, changing the state of the record.
nowKB.com