UI Actions FSM (Start Travel Start Work, Close Complete on wm_task) are not working in Worksapce

Research
Tera Guru

Hi All OOTB 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 

please refer this link: https://your instance/ sys_ui_action.do?sys_id=933bdef31b03200050fdfbcd2c071365&sysparm_record_target=sys_ui_action&sysparm...

or

Please check below OOTB ui action script

Research_0-1699776050889.png

 

Research_5-1699776257406.png

 

 

Research_1-1699776146129.png

 

Research_3-1699776178822.pngResearch_4-1699776224484.png

Please guide me with script 

Thanks.

9 REPLIES 9

Dibyaratnam
Tera Sage

I don't think it'll work on workspace as some of the unsupported methods(in workspace) has been used in the script section. such as GlideDialog, window etc.

Follow the below article for understanding.

https://www.servicenow.com/community/next-experience-articles/how-to-use-ui-actions-in-workspaces/ta...

You will need to write the whole logic inside workspace client script section to work it in the workspace side.

Research
Tera Guru

Hi @Dibyaratnam Appreciate for solutioning can you guide me the script please

 

Thanks

Can you please send the code here in editable or text format so that I can go through it.

Research
Tera Guru
 
Thanks

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);
}