How to hide Widget buttons in Service Portal for RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 09:42 PM
Hello All,
I created a Custom Widget and added in Standard Ticket configurations of Action widget.
Now its showing like this- We need to show buttons based on state.
If i click on Cancel-Then the state of the RITM goes to Closed Incomplete and If i click on Reopen then it moves to open state.
But we want to hide the buttons- If State is Open then only need to show Cancel button
if State is Closed-Incomplete then only need to show the Reopen Button.
If the state is not one of Open or Closed incomplete we don't need to show the actions.
Widget details:
HTML Body:
<div class="panel panel-default">
<div class="panel-heading">Actions</div>
<div class="panel-body">
<button type="button" class="btn btn-default btn-block" name="cancel" ng-click="c.uiAction('reopen')">Reopen</button>
<button type="button" class="btn btn-default btn-block" name="reopen" ng-click="c.uiAction('cancel')">Cancel</button>
</div>
</div>
Server Side Script:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 10:00 PM
Hi @sattar3
As we previously discussed for your requirement you will generally use AngularJS expressions directly within your widget’s HTML template. Your logic will check the current state of the ticket and display buttons accordingly.
Given the conditions you’ve outlined:
- Display the “Cancel” button if the state is “Open”.
- Display the “Reopen” button if the state is “Closed-Incomplete”.
- Do not display any buttons for other states.
<div>
<!-- Cancel Button: Only shown if state is 'Open' -->
<button ng-if="data.state == 'open'" ng-click="c.cancel()">Cancel</button>
<!-- Reopen Button: Only shown if state is 'Closed-Incomplete' -->
<button ng-if="data.state == 'closed_incomplete'" ng-click="c.reopen()">Reopen</button>
</div>
2. Server Side Script
(function() {
// Assuming ‘current’ is your RITM or ticket GlideRecord
// You might need to adjust this logic depending on
// how you’re fetching or receiving the record
data.state = current.getValue('state');
// Optionally, include translations for states or other logic as needed
})();
3. Client Side Controller
(function() {
/* widget controller */
var c = this;
c.cancel = function() {
// Logic to transition state to ‘Closed-Incomplete’
// and maybe refresh the widget or redirect
};
c.reopen = function() {
// Logic to transition state to ‘Open’
// and similarly refresh or redirect
};
})();
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma