This article demonstrates some methods to export your field and table information to excel. By merging the Form Sections, Elements, and Labels into a single export, you can save some time when creating documentation or design documents.
I create two versions below. The quick "Scripts - Background" way of doing this, and the "New Application" version that is more refined.
Remember to try this out in your development environment first. It can take some time for the script to complete.
Version 1: Scripts - Background
This is a quick way to export table information without creating a new application:
Elevate Role to security_admin
In Scripts - Background run this statement:
getFieldInfo(); function getFieldInfo() { var grSection = new GlideRecord('sys_ui_section'); grSection.query(); while (grSection.next()) { var grSectionElement = new GlideRecord('sys_ui_element'); grSectionElement.addQuery('sys_ui_section',grSection.sys_id); grSectionElement.OrderBy('position'); grSectionElement.query(); while (grSectionElement.next()) { var grLabel = new GlideRecord('sys_documentation'); grLabel.addQuery('table',grSection.name); grLabel.addQuery('element',grSectionElement.element); grLabel.query(); if (grLabel.next()) { gs.print('View: '+grSection.view.title+', Table: '+grSection.name+', Field Label: '+grLabel.label+', Field: '+grLabel.name); } } } }
Copy the results.
Open Excel and Paste the results
In Excel, Use "Data > Text to Columns" to convert the commas to columns
Version 2: Create "Table Information" Application
This is a more elegant solution:
Add Field: View, Medium (100)
Add Field: Table, Medium (100)
Add Field: Field Label, Medium (100)
Add Field: Field, Medium (100)
Tables & Columns:
Create New Table
Label: Table Information
Table Name: u_table_information
Create new application: false
Create new module: true In application: System DefinitionNavigation Bar, type: u_table_information.form
Right click > Personalize > Form Layout
Create Script Includes:
Script Includes: Name: setTableInformation Client Callable: true Script: function setTableInformation() { //Clear Table Information Table var grTableInformation = new GlideRecord('u_table_information'); grTableInformation.query(); while (grTableInformation.next()) { grTableInformation.deleteRecord(); } gs.log('Deleted Table Information Table'); //Set Table Information Table var grSection = new GlideRecord('sys_ui_section'); grSection.query(); while (grSection.next()) { var grSectionElement = new GlideRecord('sys_ui_element'); grSectionElement.addQuery('sys_ui_section',grSection.sys_id); grSectionElement.OrderBy('position'); grSectionElement.query(); while (grSectionElement.next()) { var grLabel = new GlideRecord('sys_documentation'); grLabel.addQuery('table',grSection.name); grLabel.addQuery('element',grSectionElement.element); grLabel.query(); if (grLabel.next()) { var grTableInfoRow = new GlideRecord('u_table_information'); grTableInfoRow.initialize(); grTableInfoRow.u_view = grSection.view.title; grTableInfoRow.u_table = grSection.name; grTableInfoRow.u_field_label = grLabel.label; grTableInfoRow.u_field = grLabel.name; grTableInfoRow.insert(); } } } }
Create New Module: Set Table Information
Script (from Arguments:)
Icon: images/icons/js_validate.gif
Arguments: setTableInformation();
SUPPORTING FILES
Now you can use either of the methods to export the field and table information to excel. Awesome right?!
Mike