The CreatorCon Call for Content is officially open! Get started here.

patricklatella
Mega Sage

Hi all, 

wanted to share this custom widget I created that shows a popup on the "approval" page in Service Portal.  One complaint I've often heard is that an Approver doesn't see much information about a Change Request if they view the OOB "approval" page in the Service Portal.  There is no information about Justification, Implementation Plan, etc.  This widget creates a "Show Additional Change Details" button that opens a popup that pulls values from fields on the Change Request.

find_real_file.png

 

find_real_file.png

 

Here's the code.  You can edit the fields and text that show in the popup as you like.  Hope this helps someone!

HTML:

<center>
<div>
<button class="btn btn-primary" ng-click="c.openMatrixModal()">${Show Additional Change Details}</button>
</div>
</center>

<script>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Additional Change Details</h4>
</div>
<div class="panel-body wrapper-xxxl">
<b><u>Description:</u></b><br>{{c.data.description}}<p><p>
<b><u>Justification:</u></b><br>{{c.data.justification}}<p><p>
<b><u>Implementation Plan:</u></b><br>{{data.implementation_plan}}<p><p>
<b><u>Risk and impact analysis:</u></b><br>{{data.risk_impact_analysis}}<p><p>
<b><u>Backout Plan:</u></b><br>{{data.backout_plan}}<p><p>
<b><u>Test Plan:</u></b><br>{{data.test_plan}}<p><p>
</div>
<div class="panel-footer text-right">
<button class="btn btn-primary" ng-click="c.closeModal()">${Close Popup}</button>
</div>
</div>
</script>

Client Script:

function($uibModal, $scope) {
var c = this;

 

//open popup
c.openMatrixModal = function() {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplate2',
scope: $scope
});
}

//close popup
c.closeModal = function() {
c.modalInstance.close();
}
}

Server Script:

(function() {

data.justification = '';
data.implementation_plan = '';
data.risk_impact = '';
data.backout_plan = '';
data.test_plan = '';

//get current record
var gr = $sp.getRecord();
var task = getRecordBeingApproved(gr);
if (gr == null || !gr.isValid()) {
data.isValid = false;
return;
}

//set values to pass to HTML
data.description = task.description.toString();
data.justification = task.justification.toString();
data.implementation_plan = task.implementation_plan.toString();
data.risk_impact_analysis = task.risk_impact_analysis.toString();
data.backout_plan = task.backout_plan.toString();
data.test_plan = task.test_plan.toString();

})();

Comments
Steven31
Tera Contributor

Hi @patricklatella, Thanks for sharing. However I tried it and the button is not responding. Do you have any update?

patricklatella
Mega Sage

@Steven31 Hi Steven,

can you post your scripts? 

Did you copy exactly? 

Is your widget on the "approval" page?

 

can you post some screenshots?

 

thanks,

Steven31
Tera Contributor

Hi @patricklatella ,

I've copied exactly the scripts provided above.

Screenshot 2023-02-02 162721.pngScreenshot 2023-02-02 162750.png

Screenshot 2023-02-02 162814.png

 

I've added the widget in "approval" page as below:

Screenshot 2023-02-02 162930.png

patricklatella
Mega Sage

Hi Steven,

can you show me a screenshot of an actual change approval being viewed in the portal?

Steven31
Tera Contributor

This is the actual approval page, and the “Show additional change detail” button does not respond when click.

123DA716-AA37-4977-BD53-4A6E00F5D6DC.png

patricklatella
Mega Sage

Hi Steven,

try this HTML:

 

<center>
<div>
<button class="btn btn-primary" ng-click="c.openMatrixModal()">${Show Additional Change Details}</button>
</div>
</center>

<script type="text/ng-template" id="modalTemplate2">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">Additional Change Details</h4>
</div>
<div class="panel-body wrapper-xxxl">
<b><u>Description:</u></b><br>{{c.data.description}}<p><p>
<b><u>Justification:</u></b><br>{{c.data.justification}}<p><p>
<b><u>Implementation Plan:</u></b><br>{{data.implementation_plan}}<p><p>
<b><u>Risk and impact analysis:</u></b><br>{{data.risk_impact_analysis}}<p><p>
<b><u>Backout Plan:</u></b><br>{{data.backout_plan}}<p><p>
<b><u>Test Plan:</u></b><br>{{data.test_plan}}<p><p>
</div>
<div class="panel-footer text-right">
<button class="btn btn-primary" ng-click="c.closeModal()">${Close Popup}</button>
</div>
</div>
</script>

 

 

And then be sure to view an approval request in the portal for a Change Request, your screenshot is an approval request for an RITM.  My widget only works as is for Change Request approvals.

Steven31
Tera Contributor

@patricklatella,

Perfect, this is working now. Thanks!

 

patricklatella
Mega Sage

@Steven31 Great to hear!

 

Community Alums
Not applicable

An alternate option is to show the change form with the activity stream below it. 
The Change Approval form looks like this because the widget server code doesn't accommodate fields on a table other than sc_req_item. A few lines of code and the form will look much cleaner and give the approver all the required information. Doing it this way will keep approval views consistent between Change and Request. 

 

Follow the instructions below for a more consistent approach across your approvals:

https://davidmac.pro/posts/2021-01-30-approval-page-form/ 

 

Remember that the SP view can be edited to show which fields you do and do not wish to show on the form, as the server-side code will scrape all of them. 

 

JamesBustard_0-1708477538762.png

 

Version history
Last update:
‎12-13-2021 10:05 PM
Updated by: