how to add action widget on standard page on service portal please see description

snow34
Tera Contributor

how to add action widget  on standard page on service portal like how we have for incident 

 

 

 

6 REPLIES 6

HI Deepika,

I did the same and still do not find the ' action ' dropdown for either incident or RITM as tried on PDI.

Is there anything like i need to link the my request page with 'incident standard action' widget ?

For Request:

 

sc_request.png

Widget Name: Request Standard Ticket Actions

HTML:

<div>
    <div class="dropdown" id="child-case-tabs" ng-if="data.showActions">
        <button type="button" id="actions-button" class="btn btn-default dropdown-toggle action-btn" data-toggle="dropdown" style="width : 100%" aria-haspopup="true" ng-init="setFocusOnActionButtons()">
            ${Actions}
            <span class="fa fa-caret-down"></span>
        </button>
        <ul class="dropdown-menu pull-right" id="actionList">
            <li ng-if="data.canCancel">
                <a href="javascript&colon;void(0)" ng-click="$event.stopPropagation();cancelRequest()">${Cancel Request}</a>
            </li>
        </ul>
    </div>
</div>

Server Script:

(function() {
    var requestGr = new GlideRecord('sc_request');
    var requestSysId = options.sys_id;

    if (!requestSysId && $sp.getParameter('table') == 'sc_request')
        requestSysId = $sp.getParameter('sys_id');

    if (input && input.action == 'cancelRequest' && requestGr.get(requestSysId) && hasPermissions(requestGr, "write")) {
        requestGr.request_state = 'closed_cancelled';
        requestGr.stage = 'closed_complete';
        requestGr.update();
        gs.addInfoMessage(gs.getMessage("Request cancelled."));
    }

    if (requestGr.get(requestSysId) && hasPermissions(requestGr)) {
        data.canCancel = requestGr.request_state == 'requested' || requestGr.request_state == 'in_process';
        data.showActions = data.canCancel;
    }

    function hasPermissions(gr, operation) {
        if (operation == "write" && gr.canWrite())
            return true;

        return (gr.getValue("requested_for") == gs.getUserID()) || (gr.getValue("opened_by") == gs.getUserID());
    }
    data.i18n = {};
})();

 Client Script:

function requestTicketActions($scope, $http, spUtil, $timeout, spModal, i18n, $window, $uibModal, spAriaUtil) {
    var c = this;
    c.doneLoading = false;
    c.cancelledRequestMsg = "${Cancelled Request}";

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

    $scope.cancelRequest = function() {
        $scope.data.action = 'cancelRequest';
        $scope.server.update().then(function(response){
            spAriaUtil.sendLiveMessage(c.cancelledRequestMsg);
            location.reload();
        });
        $scope.$emit('focusOnActions', {"isFocusRequired": true});
    };

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

 

Portal URL Link:
https://YOURINSTANCE.service-now.com/esc?id=hrm_ticket_page&table=sc_request&sys_id=SYSIDRECORD 
Request Button.png