UI action client script not working in SIR workspace, but working fine in native UI

AamerA
Tera Contributor

UI action client script not working in SIR workspace, but working fine in native UI.

I have created the declarative action on the related list to make the UI action visible, but when clicking on it it is not working

 

Here is the script:

 

f
function query_server() {
 
var checked_elements = g_list.getChecked();
var arr = [];
arr = checked_elements.split(',');
var numb_selected = arr.length; 
//g_form.addInfoMessage("Hey Ricky, you selected " + numb_selected + " items");
g_form.addInfoMessage("Processing for selected Machine. Server script running backend. \nThis action may take a minute. Please wait..");
for (i = 0; i < arr.length; i++) {
 
var ga = new GlideAjax('reimage_include')
ga.addParam('sysparm_name', "helloWorld");
ga.addParam('sysparm_task_ci_sys_id', arr[i]);
ga.addParam('sysparm_ticket_id', g_form.getUniqueValue());
ga.addParam('sysparm_sir_number', g_form.getDisplayValue('number'));
ga.addParam('sysparm_assigned_to', g_form.getValue('assigned_to'));
 
ga.getXML(callBackFunction);
}
}
 
function callBackFunction(response) {
var result = response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage(result);
}
 

 

6 REPLIES 6

Community Alums
Not applicable

HI @AamerA ,

When using Workspace options ensure the Client checkbox on the UI Action is set to true.

 

Hi @Community Alums , yes the client checkbox is marked as true already

Ankur Bawiskar
Tera Patron
Tera Patron

@AamerA 

Please share your configuration screenshots.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar ,

 

I have a Ui action called "Create Reimage incident" on the related list to create incident by selecting the configuration item (CI's Affected table) as below.

Ui action and script :

 

AamerA_0-1741081660922.png

 

AamerA_1-1741081802863.png

 

script include which is called in UI action:

 

AamerA_2-1741082149289.png

 

AamerA_3-1741082194780.png

 

For this to be available on the Workspace related list i have created declarative action assignment as below and calling the same script which is there in ui action as well in declarative action assignment client script, which is making the Ui action visible in the related list, but when clicking on that getting error in the browser console as  "SCRIPT:EXEC Error while running Client Script "GlideScopedScript": TypeError: g_form.getChecked is not a function"

 

 

AamerA_7-1741082672206.png

 

Declarative Action assignment:

AamerA_4-1741082415281.png

 

AamerA_5-1741082497914.png

workspace Uia ction visbility:

AamerA_6-1741082629130.png

 

could you please help me know why this error is coming, when it is working fine in Native UI and not working in workspace