Punit S
Giga Guru

Hi Rashim, 

 

To achieve the same functionality in a Workspace client script UI action, you can use the following code:

 

 

var datatemp = {};
var formFields = g_form.getEditableFields();
for (var i = 0; i < formFields.length; i++) {
    // Getting all editable fields in the form
    datatemp[formFields[i]] = g_form.getValue(formFields[i]);
    console.log(formFields[i] + ":" + datatemp[formFields[i]]);
}
var data = JSON.stringify(datatemp);

var url = '<your UI Page URL>';
var dialog = new GlideModal(url);
dialog.setTitle('Search Data');
dialog.setPreference('data', data);
dialog.render();

 

 

 

 

This code first retrieves all the editable fields in the form using g_form.getEditableFields(). It then loops through each field and retrieves the value using g_form.getValue(). The field name and value are stored in the datatemp object.

After that, the datatemp object is converted to a JSON string and passed to the UI page through the setPreference() method.

Finally, a GlideModal is used instead of GlideDialogWindow to open the UI page. This is because GlideDialogWindow is deprecated and GlideModal is the recommended method for opening UI pages in ServiceNow.

Make sure to replace <your UI Page URL> with the actual URL of your UI page.

Please mark my answer correct/helpful in case it adds value and moves you a step closer to your desired ServiceNow  solution goal. 

Thanks,
Punit