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