In Employee portal once i click on Reopen button a popup with additional comments should appear

Debasis Pati
Tera Guru

Hello All,
In Esc portal we have action called "Reopen" this shows to the resolved incidents and when clicked on it it directly makes the incident to in progress state.

What i want to achieve is when clicked on it i want to show a popup with additional comments field as mandatory and once filled values there should be a submit button once submitted it should copy that comment values to the incident's additional comments also it should make the incident InProgress the way its working now.

action link-https://yourinstance.service-now.com/std_ticket_config_action.do?sys_id=e17865a5ff0222105146ffffffffffdd&sysparm_record_target=std_ticket_config_action&sysparm_record_row=2&sysparm_record_rows=3&sysparm_record_list=ticket_configuration%3D33ad80e787f10010e0ef0cf888cb0b87%5EORDERBYorder

@Ankur Bawiskar any suggestions?

1 ACCEPTED SOLUTION

@Debasis Pati 

I was able to achieve this, see below details

-> In Standard Ticket Config Action, select "User Input" checkbox and Save the record

AnkurBawiskar_0-1766138273178.png

 

-> in related list create a new user input of type string, like this and make mandatory using checkbox

AnkurBawiskar_1-1766138288352.png

 

AnkurBawiskar_2-1766138309760.png

-> update the action script to grab the input you created and set in comments field

add this at line 7

        current.comments = inputs.u_comments;
AnkurBawiskar_3-1766138727631.png

 

Output:

make comments mandatory incident reopening using standard ticket config action.gif

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

@Debasis Pati 

I was able to achieve this, see below details

-> In Standard Ticket Config Action, select "User Input" checkbox and Save the record

AnkurBawiskar_0-1766138273178.png

 

-> in related list create a new user input of type string, like this and make mandatory using checkbox

AnkurBawiskar_1-1766138288352.png

 

AnkurBawiskar_2-1766138309760.png

-> update the action script to grab the input you created and set in comments field

add this at line 7

        current.comments = inputs.u_comments;
AnkurBawiskar_3-1766138727631.png

 

Output:

make comments mandatory incident reopening using standard ticket config action.gif

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Great Solution @Ankur Bawiskar  You are always a helping hand in learning guide.
Also you previous shared links were also helpful and good learning i have achieved this using the widget also but that comes under actions also we are not using this.
So was expecting some solution inside Reopen action itself.

Thank you so much

@Debasis Pati 

Nice to hear.

Do share that custom widget also here along with HTML, Server, Client scripts etc so that it helps future members

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Sure @Ankur Bawiskar ,

Cloned the "Incident Standard Ticket Actions" widget and updated below.

HTML:

<div>
<div class="dropdown" id="child-case-tabs" ng-if="data.showActions">
<button type="button" class="btn btn-default dropdown-toggle action-btn" data-toggle="dropdown" style="width : 100%">
${Actions}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="actionList">
<li>
<a ng-if="data.canResolve" href="javascript&colon;void(0)" ng-click="$event.stopPropagation();resolveIncident()">Resolve</a>
</li>
<li>
<a ng-if="data.canReopen" href="javascript&colon;void(0)" ng-click="$event.stopPropagation();reopenIncident()">Reopen</a>
</li>

</ul>
</div>


</div>

Note:In the HTML i have just removed the close button as i wanted to remove it once if you need from the original widget copy that:

Server script:

(function() {
    var incidentGr = new GlideRecord('incident');
    var incidentSysId = options.sys_id;

    if (!incidentSysId && $sp.getParameter('table') == 'incident')
        incidentSysId = $sp.getParameter('sys_id');

    if (!incidentSysId && $sp.getParameter('table') == 'universal_request') {
        var urGr = new GlideRecord('universal_request');
        urGr.get($sp.getParameter('sys_id'));
        incidentSysId = urGr.primary_task + "";
    }

    /* Actions - Start */
    if (input && input.action == 'resolve' && input.resolveComments!='' && incidentGr.get(incidentSysId)) {
        incidentGr.incident_state = global.IncidentState.RESOLVED;
        incidentGr.state = global.IncidentState.RESOLVED;
        incidentGr.resolved_by = gs.getUserID();
        incidentGr.close_notes = input.resolveComments;
        incidentGr.close_code="Closed/Resolved by Caller";
        incidentGr.update();
    }

    if (input && input.action == 'reopen' && input.reopenComments!='' && incidentGr.get(incidentSysId)) {
        incidentGr.incident_state = global.IncidentState.IN_PROGRESS;
        incidentGr.state = global.IncidentState.IN_PROGRESS;
        //incidentGr.assigned_to = '';

        incidentGr.comments = "Ticket reopened. \nReason for Reopen: "+'\n'+ input.reopenComments;
        incidentGr.update();
        // gs.addInfoMessage(gs.getMessage("Request reopened"));

    }


    if (input && input.action == 'closeIncident' && incidentGr.get(incidentSysId)) {
        incidentGr.incident_state = global.IncidentState.CLOSED;
        incidentGr.state = global.IncidentState.CLOSED;
        incidentGr.update();
    }

    /* Actions - End */

    /* Load incident data */
    if (incidentGr.get(incidentSysId)) {
        var incidentUtil = new global.IncidentUtils();
        data.canResolve = incidentUtil.canResolveIncidentPortal(incidentGr);
        data.canReopen = incidentUtil.canReopenIncident(incidentGr);
        data.canClose = incidentUtil.canCloseIncident(incidentGr);
        data.showActions = data.canResolve || data.canReopen || data.canClose;
    }

    data.i18n = {};

})();

Client controller:

function incidentTicketActions($scope, $http, spUtil, $timeout, spModal, i18n, $window, $uibModal) {
    /* widget controller */
    var c = this;
    c.doneLoading = false;

    var MOBILE_DEVICE_SCREEN_WIDTH = 767;
    $scope.mobileDevice = c.data.isMobile || ($window.innerWidth < MOBILE_DEVICE_SCREEN_WIDTH);


    c.Resolve = function(action) {
        c.data.action = action;
        c.server.update().then(function() {
            $scope.data.action = undefined;
            //spUtil.addInfoMessage("Incident has been resolved", 3000);

        });

    };
 
      $scope.closeIncident = function() {
        $scope.data.action = 'closeIncident';
        $scope.server.update(init);
    };

    $scope.$on('record.updated', function(name, data) {
        c.data.action == '';
        c.data.reopenComments = '';
        c.data.resolveComments= '';

        spUtil.update($scope);
    });

    c.Reopen = function(action) {
        c.data.action = action;
        c.server.update().then(function() {
            $scope.data.action = undefined;
            spUtil.addInfoMessage("Incident has been reopened", 3000);

        });

    };

    $scope.reopenIncident = function() {
        c.data.action = 'reopenIncident';
        c.modalInstance = $uibModal.open({
            templateUrl: 'modalTemplateReopen',
            scope: $scope
        });
        c.server.update(init);

    };

      $scope.resolveIncident = function() {
        $scope.data.action = 'resolveIncident';
        c.modalInstance = $uibModal.open({
            templateUrl: 'modalTemplateResolve',
            scope: $scope
        });
        c.server.update(init);
    };

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

    function init() {}

    $(document).on('click', 'div.modal-footer button.btn, ul#child-case-tabs .dropdown-menu', function(e) {
        e.stopPropagation();
    });

    $(document).bind('dragover drop', function(event) {
        event.preventDefault();
        return false;
    });

    $scope.$on('sp_loading_indicator', function(e, value) {
        if (!value && !c.doneLoading) {
            c.doneLoading = true;
        }
    });

}


Note:
also create Angulat-ng templatee in the widget's related list and click new.

ID-modalTemplateReopen
Template:
<div class="panel panel-default">
<div class="modal-header" class="panel-heading">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="$dismiss()">&times;</button>
<h4 class="panel-title">Please provide a reason for reopening:</h4>
</div>
<div class="panel-body wrapper-md">
<form name="modalTemplateReopen" ng-submit="c.Reopen('reopen')">
<div class="form-group">
<textarea required sp-autosize="true" ng-required="true" ng-model="data.reopenComments"
id="reopenComments" placeholder="Comments are required to reopen."
class="form-control ng-pristine ng-valid ng-scope ng-empty ng-touched"
aria-invalid="false"
style="overflow: hidden; word-wrap: break-word; resize: vertical;"></textarea>
</div>
<div class="text-right">
<button type="button" class="btn btn-default" style="margin-right: 15px;" data-dismiss="modal"
ng-click="$dismiss()">Cancel</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div>