Confirmation message on Service Portal Widget

mattystern
Kilo Sage

Hi all,

I had a request come in to allow for users to close their own requests (RITM) in case it was submitted in error or if it is no longer valid. I already had a "Actions Buttons" widget on my Service Portal for closing incidents, so I copied this, changed the tables, and I was able to get a working "v1" of this.

The "Action Buttons - RITM" widget is laid out here:

HTML:

<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')" ng-hide="data.hideButton">Resolve Incident</button>
 </div>
</div>

Client Side:

function() {
  var c = this;
	c.uiAction = function(action) {
		c.data.action = action;
		c.server.update().then(function() {
			c.data.action = undefined;
		})
	}
}

Server Side:

(function() {

	// Get table & sys_id
	data.table = input.table || $sp.getParameter("table");
	data.sys_id = input.sys_id || $sp.getParameter("sys_id");

	// Valid GlideRecord
	gr = new GlideRecord(data.table);
	if (!gr.isValid())
		return;

	// Valid sys_id
	if (!gr.get(data.sys_id))
		return;

	// only show button if the record is an incident and is 'New', 'In Progress' or 'On Hold'
	data.hideButton = true;
	if (data.table == 'sc_req_item' && gr.state <= '3' || data.table == 'sc_req_item' && gr.state <= '4') {
		data.hideButton = false;
	}

	if (input && input.action) {
		var action = input.action;

		// If RITM table
		if (data.table == 'sc_req_item') {
			if (action == 'close_ritm') {
				//Close RITM
				gr.setValue('state', 4);
				gr.setValue('closed_by', gs.getUserID());
				gr.setValue('work_notes', "RITM Closed by Requestor")
				gr.update();
			}
		}
	}
})();

I call the action "close_ritm" which was a UI Action I built based off of the "close_sc_task" UI Action. Inside of this UI Action, I have a confirmation message:

find_real_file.png

For this, I am using if(confirm"My text here"); on the UI Action. This is working fine here, but does not apply to the Service Portal when using the newly created "Close Request" button. I thought this called the same UI Action. Is there something I can add to my widget which will do something similar to the UI Action? Guessing it needs to be on the client script but I do not work much with widgets on the Service Portal...

Any help is appreciated!

1 ACCEPTED SOLUTION

Sourav16
Kilo Guru

Hi,

You can look into the spModal API for achieving this.

Hope this helps

 

Thanks 

Sourav

View solution in original post

7 REPLIES 7

Sourav16
Kilo Guru

Hi,

You can look into the spModal API for achieving this.

Hope this helps

 

Thanks 

Sourav

Hi,

If it solved your problem then you can mark the reply as correct for others reference.

 

Thanks 

Sourav

Hi Sourav,

This was helpful but I am wondering how to link the server side script to these functions? The documentation shows html / client side links, but I am not having much success then linking this to actually update anything on the server.

I was able to figure it out. Thanks again Sourav!