The Zurich release has arrived! Interested in new features and functionalities? Click here for more

CSV Export Function

Koki
Tera Contributor

Hi,

Regarding the CSV export function shown in the next image, where is this defined?

find_real_file.png

 


We need to create a new UIAction that includes CSV export functionality and would like to reference existing CSV export definitions, scripts, etc.

 

Please can someone help me out. Thank you in advance.

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Koki,

Filter on Name = "CSV" to find the csv export script. Unfortunately, it's calling internal Java class with GlideList2 as an argument. ContextMenuExportHandler() seems like it can be used in UI Action but since it's undocumented, it may be difficult to customize it.

FYI, the second argument 'unload_csv' can be switched to 'unload_xml' to export to xml, 'unload_json' to export to json. Seems like the syntax is 'unload_xxx' to export in xxx format.

https://developer.servicenow.com/dev.do#!/reference/api/rome/client/c_GlideList2API?navFilter=glidel...

/**
  * Script executed on the Client for this menu action
  *
  * The following variables are available to the script:
  *    'g_list' the GlideList2 that the script is running against (only valid for List context menus)
  *    'g_fieldName' the name of the field that the context menu is running against (only valid for List context menus)
  *    'g_sysId' the sys_id of the row or form that the script is running against
  *    'rowSysId' is also set to the sys_id of the row to support legacy actions, but g_sysId is preferred
  */
 runContextAction();
  
 function runContextAction() {
    var exportHandler = new ContextMenuExportHandler(g_list,'unload_csv');
    exportHandler.exportRecords();
 }

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can create your own UI context menus

find_real_file.png

Regards
Ankur

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

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Koki,

Filter on Name = "CSV" to find the csv export script. Unfortunately, it's calling internal Java class with GlideList2 as an argument. ContextMenuExportHandler() seems like it can be used in UI Action but since it's undocumented, it may be difficult to customize it.

FYI, the second argument 'unload_csv' can be switched to 'unload_xml' to export to xml, 'unload_json' to export to json. Seems like the syntax is 'unload_xxx' to export in xxx format.

https://developer.servicenow.com/dev.do#!/reference/api/rome/client/c_GlideList2API?navFilter=glidel...

/**
  * Script executed on the Client for this menu action
  *
  * The following variables are available to the script:
  *    'g_list' the GlideList2 that the script is running against (only valid for List context menus)
  *    'g_fieldName' the name of the field that the context menu is running against (only valid for List context menus)
  *    'g_sysId' the sys_id of the row or form that the script is running against
  *    'rowSysId' is also set to the sys_id of the row to support legacy actions, but g_sysId is preferred
  */
 runContextAction();
  
 function runContextAction() {
    var exportHandler = new ContextMenuExportHandler(g_list,'unload_csv');
    exportHandler.exportRecords();
 }

Thank you very much.

We will take this into consideration as a reference.