UI Action 'Confirm()' on Agent Workspace

john_duchock
Kilo Guru

I am building up our agent workspace for an eventual go-live and have run into a snag.  In our "native" application, we have a UI Action that allows a user to create a problem record directly from an incident using a UI Action.  This UI Action includes a confirmation that warns the user that they are about to initiate the problem process which includes Senior Management Notifications.

I have tried to update this UI Action to include a confirmation when used in the Agent Workspace, but it does not seem to work.  The "first pass" (client side) seems to work fine, but i am not sure the Agent Workspace is passing the UI Action "action name" properly on line 5:

gsftSubmit(null, g_form.getFormElement(), 'create_problem');

Again, this works perfectly in the "native" forms, but not in workspace.

I have tried to move the entire script to the Workspace Client Script (using onClick(g_form)) but that does not seem to work either (client side works, server side does not)...

Code below...anyone have any luck getting confirm() working on a workspace UI Action?

function createProblem(){
      var answer=confirm("Are you sure you wish to create a Problem Record?\n\nNOTE:  This will initiate the Problem Management Process which includes Senior Executive Notifications.");
      if (answer==true)
              {
              gsftSubmit(null, g_form.getFormElement(), 'create_problem'); //MUST call the 'Action name' set in this UI Action
      }
      else
              {
              return false;
      }
}

if(typeof window == 'undefined')
      {
var prob = new GlideRecord("problem");
prob.short_description = current.short_description;
prob.cmdb_ci = current.cmdb_ci;
prob.cmdb_ci = current.cmdb_ci;
prob.business_service = current.business_service;
prob.priority = current.priority;
prob.company = current.company;
prob.sys_domain = current.sys_domain;

//set Problem Impact according to Incident Impact...using the stupid sys_choice values that my predecessor created for incident... 
if (current.impact == 0){ // All stores/users = High
	prob.impact = 1;
}
if (current.impact == 4){ // Multi user/store = medium
	prob.impact = 2;
}
if (current.impact == 5){ // single user / store = low
	prob.impact = 3;
}

//set Problem Urgency according to Incident Urgency...and oh, look...they made the same stupid mistake twice by not using OOTB sys_choice values...yayfun
if (current.urgency == 6){ //Inconvenience = low
	prob.urgency = 3;
}
if (current.urgency == 5){ //Degradation = medium
	prob.urgency = 2;
}
if (current.urgency == 4){ //Outage = high
	prob.urgency = 1;
}

var sysID = prob.insert();

current.problem_id = sysID;
current.state = -2;
var mySysID = current.update();

action.setRedirectURL(prob);
action.setReturnURL(current);
gs.addInfoMessage("Problem " + prob.number + " created");
}
1 ACCEPTED SOLUTION

denumchikin1
Tera Contributor

Hi John - Try copying your client side portion into the UI action's Workspace client script, and replace gsftSubmit with g_form.submit method (example below).

var answer = confirm("Are you sure you wish to create a Problem Record?\n\nNOTE:  This will initiate the Problem Management Process which includes Senior Executive Notifications.");

if (answer == true)
  g_form.submit('create_problem');
else
  return false;
      

Edit: Added code portion and rewrote answer to be more concise.

View solution in original post

4 REPLIES 4

denumchikin1
Tera Contributor

Hi John - Try copying your client side portion into the UI action's Workspace client script, and replace gsftSubmit with g_form.submit method (example below).

var answer = confirm("Are you sure you wish to create a Problem Record?\n\nNOTE:  This will initiate the Problem Management Process which includes Senior Executive Notifications.");

if (answer == true)
  g_form.submit('create_problem');
else
  return false;
      

Edit: Added code portion and rewrote answer to be more concise.

john_duchock
Kilo Guru

Thanks for getting me close @denumchikin ...  but instead of specifying the action, called it.  The following is the "workspace client script" that is now working !

 

function onClick (g_form){
	if ( !confirm('Are you sure you wish to create a problem record?') )
		return;
	
	g_form.submit( g_form.getActionName() );
}

Hi @john_duchock & @denumchikin1 ,

 

I used the same lines of code but My Approve button is not working. Even it is not showing the confirmation question.

Meh...we stopped using agent workspace and are now using the Polaris interface instead...  it was the obvious next evolution and we didn't have to build specific UI Actions...