Adding button in widget to change state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2024 09:36 PM
in the "Ticket Conversations" widget in portal I need to add a button name "Change state". It should change case state to 11.
I have created a UI action "Change state" which will change the state.
I need to call it in widget "Ticket Conversations".
Update widget but it is not changing the status, anyone help?
HTML section:
<button type="button" class="btn btn-primary btn-block" ng-click="c.uiAction('respond_requestor')">Respond From Requestor</button>
client controller:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2024 09:53 PM
Hi @Hafsa1
Verify that it correctly updates the state to 11.
current.state = 11; current.update();
Update HTML
<button type="button" class="btn btn-primary btn-block" ng-click="c.uiAction('change_state')">Change State</button>
Modify Client Controller
c.uiAction = function(action) {
c.data.action = action;
c.server.update().then(function(response) {
c.data.action = undefined;
// Handle successful state update
if (response.data.success) {
alert("State changed successfully!");
// Optionally reload or navigate the page if needed
$window.location.reload();
} else {
alert("Failed to change state. Please try again.");
}
});
};
modify Server Side in the Widgets
(function() {
if (input && input.action === 'change_state') {
// Load the current record
var gr = new GlideRecord('sn_customerservice_case');
if (gr.get(input.sys_id)) {
gr.state = 11; // Set the state to 11
gr.update();
data.success = true; // Send success response
} else {
data.success = false; // Handle record not found
}
}
})();
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2024 10:52 PM - edited ‎12-12-2024 11:11 PM
can we add one condition in button that if the status is 8 then only this button should be visible.
and additional comments should be mandatory once clicked on this button