How to change the position of Reopen and Cancel Buttons in RITM Service Portal

sattar3
Tera Contributor

Hello All,

 

1. I created a Widget with the below script.

 

Body HTML template

<div class="panel panel-default">
<div class="panel-heading">Actions</div>
<div class="panel-body">
<button type="button" class="btn btn-primary btn-block" ng-click="c.uiAction('resolve')">Reopen Request</button>
<button type="button" class="btn btn-default btn-block" ng-click="c.uiAction('cancel')">Cancel Request</button>
</div>
</div>

 

widget is showing at right side of the homepage, but we need to show it on RITM's short description right side.

sattar3_0-1711515523452.png

and actions should a dropdown, please help me on this.

 

2. Reopen button will appear if the state is closed complete only for 5days, after 5 days the action button shall disappear. If the requestor click on Reopen button then the REQ and the RITM shall go back into Open, and RITM in stage fulfillment.

 

3. Cancel Request button will appear if the state of the Request is Open or waiting for approval.

If the requestor click Cancel Request button then the RITM and REQ will set to

RITM Stage: request cancelled and State: Closed Incomplete.

 

Can someone please help me on this.

 

@Ankur Bawiskar @Community Alums @SANDEEP28 @Amit Gujarathi 

 

 

Thanks,

Sattar

 

1 REPLY 1

Deepak Shaerma
Kilo Sage

Hi @sattar3 
HTML Template (Modified for dropdown):


<div class=“panel panel-default”>
<div class=“panel-heading”>Actions</div>
<div class=“panel-body”>
<select class=“form-control” ng-model=“c.action” ng-change=“c.uiAction(c.action)”>
<option value=“”>Select Action</option>
<option value=“resolve”>Reopen Request</option>
<option value=“cancel”>Cancel Request</option>
</select>
</div>
</div>

 
2. Conditional Display of Actions and Logic Implementation:
You’ll need to introduce conditions within both your Client Script and Server Script parts of the widget.

Client Script (example idea):


(function() {
var serverOptions = {
getRITMData: true // Tells the server script to get RITM information
};

c.uiAction = function(action) {
if (action === ‘resolve’) {
// Call server to reopen
c.server.get({action: ‘reopen’});
} else if (action === ‘cancel’) {
// Call server to cancel
c.server.get({action: ‘cancel’});
}
};

if (options.getRITMData) {
c.server.get(serverOptions).then(function(response) {
c.data = response.data;
});
}
})();



Server Script (simplified logic):


(function() {
if (input && input.action) {
if (input.action === ‘reopen’) {
// Logic to reopen request
} else if (input.action === ‘cancel’) {
// Logic to cancel request
}
}

// Example of getting RITM data and determining if action buttons should be displayed
if (options.getRITMData) {
var ritmGR = new GlideRecord(‘sc_req_item’);
ritmGR.get($sp.getParameter(‘sys_id’)); // Assume sys_id is passed somehow

data.showReopen = false;
data.showCancel = false;

// Check conditions and set data properties accordingly
if (ritmGR.state == ‘closed_complete’ && /* Check for 5-day condition here */) {
data.showReopen = true;
} else if (ritmGR.state == ‘open’ || ritmGR.state == ‘waiting_for_approval’) {
data.showCancel = true;
}
}
})();

 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