Using UI page in workspace client script - for configurable workspace

MS25
Mega Sage

I am trying to call a UI page from workspace client script of a UI action
here is the OOTB script of UI action:
==============================
function openFollowOnPopUp(){
  var dialogClass;
  try {
     dialogClass = GlideModal;
  } catch(e) {
    dialogClass = GlideDialogWindow;
  }
  var dialog = new dialogClass("service_management_task_closed_incomplete");
  dialog.setWidth("550");
  dialog.setTitle("Close Incomplete");
  dialog.setPreference("sys_id", g_form.getUniqueValue());
  dialog.setPreference("work_notes", g_form.getValue("work_notes"));
  dialog.setPreference("state_flow_id", "41dfa2e0d7630100fceaa6859e61035d");
  dialog.render(); //Open the dialog
}==============================
I created this and it shows the UI page but not passing variable from current record to UI page
 Workspace client script: shows the modal, take the value but not doing anything.
==========================================
function onClick(g_form) {
var ui_page_id = '03d9bd5fdf81300068c383f36bf26312';
  g_modal.showFrame({
    url: '/ui_page.do?sys_id=' + ui_page_id,
    title: 'Close Incomplete',
  })
  .then(function(modalResult) {
g_form.setValue('sys_id', g_form.getUniqueValue());
g_form.setValue('work_notes', g_form.getValue("work_notes"));
g_form.setValue('state_flow_id', '41dfa2e0d7630100fceaa6859e61035d');
g_form.save();
},
function(error) {
location.reload(); //to refresh the page if "cancel" or "X" is clicked
});
}

4 REPLIES 4

Maik Skoddow
Tera Patron
Tera Patron

HGi @MS25 

Workspaces are based on a complete new technology and it's very difficult to reuse UIO Pages from the old world.

Instead, rebuild your script nailed to the new options. See the following article for an inspiration: https://www.servicenow.com/community/next-experience-articles/how-to-use-ui-actions-in-workspaces/ta... 

Maik

I tried this using the link you provided. Question is how do we pass current records field data to UI page in this script. Just like UI action script (first script in question) is passing? 

 

====================================================

function onClick(g_form) {
var ui_page_id = '03d9bd5fdf81300068c383f36bf26312';
  g_modal.showFrame({
    url: '/ui_page.do?sys_id=' + ui_page_id,
    title: 'Close Incomplete',
  })
  .then(function(modalResult) {
g_form.setValue('sys_id', g_form.getUniqueValue());
g_form.setValue('work_notes', g_form.getValue("work_notes"));
g_form.setValue('state_flow_id', '41dfa2e0d7630100fceaa6859e61035d');
g_form.save();
},
function(error) {
location.reload(); //to refresh the page if "cancel" or "X" is clicked
});
}

PLaxmiPrasanna
Tera Contributor

Was this fixed?

Angelo Paulo Ad
Tera Contributor

Same issue as well here. Want to pass some values to a UI Page then when you interact with a UI page you get a result that gets passed to the form.