How to convert UI Action for use on Service Operations Workspace

JordanDR
Tera Contributor

Hi community,

 

I have the following UI action on the incident form to put an incident on hold.

 

function IncidentInternalHold(){
   //Set the 'task state' to 'closed complete', and display mandatory fields
   g_form.setValue('incident_state', 9);
   // g_form.setValue('active', 0);

   if (g_form.getValue('comments') == '') {
      //Remove any existing field message, set comments mandatory, and show a new field message
      try {g_form.hideFieldMsg('comments');} catch(e) {}
      g_form.setMandatory('comments', true);
      //g_form.showFieldMsg('comments','Customer Comments are required when placing an Incident on hold.','error');
	  alert('Customer Comments are required when placing an Incident on hold.','error');
      return false;  //Abort submission
   }
   //Call the UI Action and skip the 'onclick' function
   gsftSubmit(null, g_form.getFormElement(), 'IncidentInternalHold'); //MUST call the 'Action name' set in this UI Action
}

//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
   serverResolve();

function serverResolve(){
   current.incident_state = 9;
   //current.active=0;
   current.update();
   action.setRedirectURL(current);
}

 

  

I'm wanting to move this over to Service Operations Workspace but I am having issues. I clicked the checkbox to enable the workspace form button. Is there something that I'm missing here, do I need to put something on in the client script?

 

Thanks,

1 ACCEPTED SOLUTION

Karan Chhabra6
Mega Sage
Mega Sage

Hi @JordanDR ,

 

You need to write a seperate workspace client script in order to make it work in workspace as well, please refer to the below script and add it to the workspace client script

function onClick(g_form) {

    g_form.setValue('incident_state', 9);
    if (g_form.getValue('comments') == '') {

        try {
            g_form.hideFieldMsg('comments');
        } catch (e) {}
        g_form.setMandatory('comments', true);

        alert('Customer Comments are required when placing an Incident on hold.', 'error');
        return false;
    } else {

        g_form.submit(g_form.getActionName());
        g_form.save();

    }
}

KaranChhabra6_0-1685396468887.png

 

 

If my answer has helped with your question, please mark it as correct and hepful

 

Thanks!

View solution in original post

2 REPLIES 2

Karan Chhabra6
Mega Sage
Mega Sage

Hi @JordanDR ,

 

You need to write a seperate workspace client script in order to make it work in workspace as well, please refer to the below script and add it to the workspace client script

function onClick(g_form) {

    g_form.setValue('incident_state', 9);
    if (g_form.getValue('comments') == '') {

        try {
            g_form.hideFieldMsg('comments');
        } catch (e) {}
        g_form.setMandatory('comments', true);

        alert('Customer Comments are required when placing an Incident on hold.', 'error');
        return false;
    } else {

        g_form.submit(g_form.getActionName());
        g_form.save();

    }
}

KaranChhabra6_0-1685396468887.png

 

 

If my answer has helped with your question, please mark it as correct and hepful

 

Thanks!

Hi Karan,

I need help regarding UI action visibility on SOW view. There are 2 dropdowns on workspace view and after configuring UI action for workspace view, it is getting added to the unexpected dropdown. Is there any way that UI Action can be added to the drop down where it is required?

I have attached 2 screenshots where Capture1 means where I want it to be visible [next to Save button] and Capture2 means where it is visible [next to Resolve button].