Ui actions are are not working in Worksapce

Research
Tera Guru

Hi all 

Has any one worked on workspace 

Hi All  ui action of FSM  is working fine in native view but not working in configurable workspace view 

Can any one guide any script or what I am missing on it 

 

I have enaled the workspace button and workspace menu 

There is a client script which need to develop can any one help me with script please 

 

Research_0-1699886730377.png

Thanks 

 

 

8 REPLIES 8

Research
Tera Guru

Hi @Mohan Mallapu 

Thankyou for response  

PFA: 

function checkUpstreamWork() {
   var gajax = new GlideAjax("SMTaskDependency");
   gajax.addParam("sysparm_name", "checkUpstreamTasks");
   gajax.addParam("state_flow_id", "b48e00ead7201100158ba6859e6103c7");
   gajax.addParam("sysparm_uuid", g_form.getUniqueValue());
   gajax.getXMLAnswer(ajaxResponse);
}

function ajaxResponse(response) {
   if (response == 'true')
      showDialogWork();
   else {
      gsftSubmit(null, g_form.getFormElement(), gel('start_work').value);
      var ajax = new GlideAjax('GeolocationAJAX');
      ajax.addParam('sysparm_name', 'checkTracking');
      ajax.addParam('sysparm_usersysid', g_user.userID);
      ajax.getXML(function(response){
      var isUserTracked = response.responseXML.documentElement.getAttribute("answer");
      var result = isUserTracked.split(',');
      if(result[0] == 'true') {
          navigator.geolocation.getCurrentPosition(
              function (position) {
                  var ajax = new GlideAjax('GeolocationAJAX');
                  ajax.addParam('sysparm_name', 'storeGeolocationHistory');
                  ajax.addParam('sysparm_usersysid', g_user.userID);
                  ajax.addParam('sysparm_latitude', position.coords.latitude);
                  ajax.addParam('sysparm_longitude', position.coords.longitude);
                  ajax.addParam('sysparm_action', 'Start Work');
                  ajax.addParam('sysparm_task', g_form.getUniqueValue());
                  ajax.getXML();
              });
        }
    });
   }
 }

function showDialogWork() {
    var dialogClass;
    try {
         dialogClass = GlideModal;
    } catch(e) {
        dialogClass = GlideDialogWindow;
    }
    var dialog = new dialogClass("sm_open_task_upstream_work"); //Render the dialog containing the UI Page 'task_comments_dialog'
    dialog.setTitle("Are you sure?"); //Set the dialog title
    dialog.setPreference("sys_id", g_form.getUniqueValue());
    dialog.setPreference("short_text", "Open task dependencies still remain, are you sure you would like to start work?");
    dialog.setPreference('state_flow_id', 'b48e00ead7201100158ba6859e6103c7');
    dialog.render(); //Open the dialog
}

if (typeof window == 'undefined')
    serverStartWork();

function serverStartWork() {
    new global.StateFlow().processFlow(current, 'b48e00ead7201100158ba6859e6103c7', 'manual');
    //Moving redirect from state flow to UI action
    action.setRedirectURL(current);
}

Mohan Mallapu
Kilo Sage

@Research  Please update the below script in workspace script and try.

function onClick(g_form) {
 var gajax = new GlideAjax("SMTaskDependency");
   gajax.addParam("sysparm_name""checkUpstreamTasks");
   gajax.addParam("state_flow_id""b48e00ead7201100158ba6859e6103c7");
   gajax.addParam("sysparm_uuid", g_form.getUniqueValue());
   gajax.getXMLAnswer(ajaxResponse);
}
function ajaxResponse(response) {
   if (response == 'true')
      showDialogWork();
   else {
  g_form.submit('start_work');  // Action name of the UI action.
      var ajax = new GlideAjax('GeolocationAJAX');
      ajax.addParam('sysparm_name''checkTracking');
      ajax.addParam('sysparm_usersysid', g_user.userID);
      ajax.getXML(function(response){
      var isUserTracked = response.responseXML.documentElement.getAttribute("answer");
      var result = isUserTracked.split(',');
      if(result[0] == 'true') {
          navigator.geolocation.getCurrentPosition(
              function (position) {
                  var ajax = new GlideAjax('GeolocationAJAX');
                  ajax.addParam('sysparm_name''storeGeolocationHistory');
                  ajax.addParam('sysparm_usersysid', g_user.userID);
                  ajax.addParam('sysparm_latitude', position.coords.latitude);
                  ajax.addParam('sysparm_longitude', position.coords.longitude);
                  ajax.addParam('sysparm_action''Start Work');
                  ajax.addParam('sysparm_task', g_form.getUniqueValue());
                  ajax.getXML();
              });
        }
    });
   }
 }

 

function showDialogWork() {
    var dialogClass;
    try {
         dialogClass = GlideModal;
    } catch(e) {
        dialogClass = GlideDialogWindow;
    }
    var dialog = new dialogClass("sm_open_task_upstream_work"); //Render the dialog containing the UI Page 'task_comments_dialog'
    dialog.setTitle("Are you sure?"); //Set the dialog title
    dialog.setPreference("sys_id", g_form.getUniqueValue());
    dialog.setPreference("short_text""Open task dependencies still remain, are you sure you would like to start work?");
    dialog.setPreference('state_flow_id''b48e00ead7201100158ba6859e6103c7');
    dialog.render(); //Open the dialog
}



Mohan Mallapu
Kilo Sage

@Research 

Mark my answer as  Accepted if I have answered your question.

Mohan Mallapu
Kilo Sage

@Research 

Mark my answer as  Accepted if I have answered your question.