How to call a script include scoped from UI action

Anna_Servicenow
Tera Guru

I am pretty new to UI action

 

Can someone help on how can I use the below script in a UI action- form button, instead of an onsubmit client script. I need to check the current record has an attachment before the script runs

function onSubmit() {

    var systemId = g_form.getUniqueValue();
    var ga = new GlideAjax('AttachmentParserScoped');
    ga.addParam('sysparm_name', 'getExcelInfo');
    ga.addParam('sysparm_sys_id', systemId);
    ga.getXMLAnswer(showDetails);

    function showDetails(answer) {
   }
1 ACCEPTED SOLUTION

Juhi Poddar
Kilo Patron

Hello @Anna_Servicenow 

  • Create a new record in sys_ui_action table.
  • Fill the details as shown in the screenshot below and modify as required.

Screenshot1:

JuhiPoddar_0-1736796734897.png

Screenshot2:

JuhiPoddar_2-1736796959645.png

Script:

function showDetails() {
    var systemId = g_form.getUniqueValue();
    var ga = new GlideAjax('AttachmentParserScoped');
    ga.addParam('sysparm_name', 'getExcelInfo');
    ga.addParam('sysparm_sys_id', systemId);
    ga.getXMLAnswer(showDetails);

    function showDetails(answer) {
		alert(answer);
	}
}

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

View solution in original post

1 REPLY 1

Juhi Poddar
Kilo Patron

Hello @Anna_Servicenow 

  • Create a new record in sys_ui_action table.
  • Fill the details as shown in the screenshot below and modify as required.

Screenshot1:

JuhiPoddar_0-1736796734897.png

Screenshot2:

JuhiPoddar_2-1736796959645.png

Script:

function showDetails() {
    var systemId = g_form.getUniqueValue();
    var ga = new GlideAjax('AttachmentParserScoped');
    ga.addParam('sysparm_name', 'getExcelInfo');
    ga.addParam('sysparm_sys_id', systemId);
    ga.getXMLAnswer(showDetails);

    function showDetails(answer) {
		alert(answer);
	}
}

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar