Add a confirmation message to a widget on the portal

JuliaHowells
Tera Expert

Hi SN Experts, 

I currently have a widget on the Portal that, when clicked, creates a child incident and associates the parent. 

 

We want to add a pop-up message to this that tells the user they've been added and they must click OK to close the pop-up. 

 

<button type="button" class="btn btn-primary btn-block" ng-click="sysverb_child_new()">Add me to this issue</button>

 

// Server Script
(function() {

    // Get table & sys_id
    data.sys_id = input.sys_id || $sp.getParameter("sys_id");
    //input
    if (input && input.action == 'sysverb_child_new') {
        var sr = new GlideRecord('incident');
        if (sr.get(data.sys_id)) {

            var jr = new GlideRecord('incident');
            jr.initialize();

            jr.setValue('incident_state', 'Assigned');
            jr.setValue('state', 9);
            jr.setValue('assigned_to', sr.assigned_to);
			jr.setValue('assignment_group', sr.assignment_group);
            jr.setValue('short_description', sr.short_description);
            jr.setValue('description', sr.description);
            jr.setValue('caller_id', gs.getUserID());
            jr.setValue('parent_incident', data.sys_id);
            jr.setValue('u_on_behalf_of', gs.getUserID());
            jr.setValue('u_callback_number', gs.getUser().getRecord().getValue('phone'));
            jr.setValue('location', gs.getUser().getRecord().getValue('location'));
            jr.setValue('contact_type', 'self-service');
            jr.setValue('category', sr.category);
            jr.setValue('subcategory', sr.subcategory);
            jr.setValue('impact', sr.impact);
            jr.setValue('urgency', sr.urgency);

            var sysIdTemp = jr.insert();
        }
    }
})();

I had this as an info message (see below code) but users seem to be missing / overlooking it. 

// Client Controller

api.controller = function($scope,spUtil) {
    var c = this;
    $scope.sysverb_child_new = function() {
        var clientObj = {action:'sysverb_child_new'};
        c.server.get(clientObj).then(function(response) {
            spUtil.addInfoMessage("You've been added to this Incident", 3000);
			$sp.getWidget();
            c.data = response.data;
        })
    }

};

 

1 ACCEPTED SOLUTION

Anirudh Pathak
Mega Sage

Hi @JuliaHowells ,

You can just use "alert" to show "ok" button.

alert("You've been added to this Incident");

You can use below code - 

api.controller = function($scope,spUtil) {
    var c = this;
    $scope.sysverb_child_new = function() {
        var clientObj = {action:'sysverb_child_new'};
        c.server.get(clientObj).then(function(response) {
            alert("You've been added to this Incident"); // This will give you an alert with ok button
			$sp.getWidget();
            c.data = response.data;
        })
    }

};

 

View solution in original post

1 REPLY 1

Anirudh Pathak
Mega Sage

Hi @JuliaHowells ,

You can just use "alert" to show "ok" button.

alert("You've been added to this Incident");

You can use below code - 

api.controller = function($scope,spUtil) {
    var c = this;
    $scope.sysverb_child_new = function() {
        var clientObj = {action:'sysverb_child_new'};
        c.server.get(clientObj).then(function(response) {
            alert("You've been added to this Incident"); // This will give you an alert with ok button
			$sp.getWidget();
            c.data = response.data;
        })
    }

};