Table and columns names

sujithanagaraju
Kilo Contributor

Hi..Is there any possible way to get columns names for each table by using java script?

Thanks,

Sujitha nagaraju

1 ACCEPTED SOLUTION

bernyalvarado
Mega Sage

For instance... here goes an example for the sys_user table:



Code


var grSysDic = new GlideRecord('sys_dictionary');


grSysDic.addQuery('name','sys_user');


grSysDic.query();


while (grSysDic.next()){


    gs.print(' Table Name: ' + grSysDic.name + ' Column Name: ' + element + ' Column Label: ' + column_label );


}



Output


*** Script: Table Name: sys_user Column Name: Column Label:


*** Script: Table Name: sys_user Column Name: accumulated_roles Column Label: Accumulated roles


*** Script: Table Name: sys_user Column Name: active Column Label: Active


*** Script: Table Name: sys_user Column Name: agent_status Column Label: Work agent status


*** Script: Table Name: sys_user Column Name: building Column Label: Building


*** Script: Table Name: sys_user Column Name: calendar_integration Column Label: Calendar integration


*** Script: Table Name: sys_user Column Name: city Column Label: City


*** Script: Table Name: sys_user Column Name: company Column Label: Company


*** Script: Table Name: sys_user Column Name: cost_center Column Label: Cost center


*** Script: Table Name: sys_user Column Name: country Column Label: Country code


*** Script: Table Name: sys_user Column Name: date_format Column Label: Date format


*** Script: Table Name: sys_user Column Name: default_perspective Column Label: Default perspective


*** Script: Table Name: sys_user Column Name: department Column Label: Department


*** Script: Table Name: sys_user Column Name: edu_status Column Label: EDU Status


*** Script: Table Name: sys_user Column Name: email Column Label: Email


*** Script: Table Name: sys_user Column Name: employee_number Column Label: Employee number


*** Script: Table Name: sys_user Column Name: failed_attempts Column Label: Failed login attempts


*** Script: Table Name: sys_user Column Name: first_name Column Label: First name


*** Script: Table Name: sys_user Column Name: gender Column Label: Gender


*** Script: Table Name: sys_user Column Name: geolocation_tracked Column Label: Geolocation tracked


*** Script: Table Name: sys_user Column Name: home_phone Column Label: Home phone


*** Script: Table Name: sys_user Column Name: internal_integration_user Column Label: Internal Integration User


*** Script: Table Name: sys_user Column Name: introduction Column Label: Prefix


*** Script: Table Name: sys_user Column Name: last_login Column Label: Last login


*** Script: Table Name: sys_user Column Name: last_login_device Column Label: Last login device


*** Script: Table Name: sys_user Column Name: last_login_time Column Label: Last login time


*** Script: Table Name: sys_user Column Name: last_name Column Label: Last name


*** Script: Table Name: sys_user Column Name: last_password Column Label: Last password


*** Script: Table Name: sys_user Column Name: last_position_update Column Label: Last position update


*** Script: Table Name: sys_user Column Name: latitude Column Label: Latitude


*** Script: Table Name: sys_user Column Name: ldap_server Column Label: LDAP server


*** Script: Table Name: sys_user Column Name: location Column Label: Location


*** Script: Table Name: sys_user Column Name: locked_out Column Label: Locked out


*** Script: Table Name: sys_user Column Name: longitude Column Label: Longitude


*** Script: Table Name: sys_user Column Name: manager Column Label: Manager


*** Script: Table Name: sys_user Column Name: middle_name Column Label: Middle name


*** Script: Table Name: sys_user Column Name: mobile_phone Column Label: Mobile phone


*** Script: Table Name: sys_user Column Name: name Column Label: Name


*** Script: Table Name: sys_user Column Name: notification Column Label: Notification


*** Script: Table Name: sys_user Column Name: on_schedule Column Label: On schedule


*** Script: Table Name: sys_user Column Name: password_needs_reset Column Label: Password needs reset


*** Script: Table Name: sys_user Column Name: phone Column Label: Business phone


*** Script: Table Name: sys_user Column Name: photo Column Label: Photo


*** Script: Table Name: sys_user Column Name: preferred_language Column Label: Language


*** Script: Table Name: sys_user Column Name: roles Column Label: Roles


*** Script: Table Name: sys_user Column Name: schedule Column Label: Schedule


*** Script: Table Name: sys_user Column Name: source Column Label: Source


*** Script: Table Name: sys_user Column Name: state Column Label: State / Province


*** Script: Table Name: sys_user Column Name: street Column Label: Street


*** Script: Table Name: sys_user Column Name: sys_class_name Column Label: Class


*** Script: Table Name: sys_user Column Name: sys_created_by Column Label: Created by


*** Script: Table Name: sys_user Column Name: sys_created_on Column Label: Created


*** Script: Table Name: sys_user Column Name: sys_domain Column Label: Domain


*** Script: Table Name: sys_user Column Name: sys_domain_path Column Label: Domain Path


*** Script: Table Name: sys_user Column Name: sys_id Column Label: Sys ID


*** Script: Table Name: sys_user Column Name: sys_mod_count Column Label: Updates


*** Script: Table Name: sys_user Column Name: sys_updated_by Column Label: Updated by


*** Script: Table Name: sys_user Column Name: sys_updated_on Column Label: Updated


*** Script: Table Name: sys_user Column Name: time_format Column Label: Time format


*** Script: Table Name: sys_user Column Name: time_zone Column Label: Time zone


*** Script: Table Name: sys_user Column Name: title Column Label: Title


*** Script: Table Name: sys_user Column Name: user_name Column Label: User ID


*** Script: Table Name: sys_user Column Name: user_password Column Label: Password


*** Script: Table Name: sys_user Column Name: vip Column Label: VIP


*** Script: Table Name: sys_user Column Name: web_service_access_only Column Label: Web service access only


*** Script: Table Name: sys_user Column Name: zip Column Label: Zip / Postal code



Thanks,


Berny


View solution in original post

10 REPLIES 10

Thanks.

Per comment to Berny above we use it for BI reporting.

I'm not sure of all the reports/dashboards that the BI has created; I think it's mostly general stats on how we're adhering to SLAs (i.e. ignoring time when the call's awaiting user responses, or awaiting closure confirmation), so that management can see SLA adherence by system, team and individual without their stats being damaged by non-responsive users or poor quality tickets.

For my own team I've generated a few quick scripts to help us with incident management and problem management.  i.e. For the CI's we support it'll show any closed incidents which were closed by workaround, but for which we've not associated a problem ticket, and will mail the person who closed that ticket reminding them to assign it to a PRB.  For the problems it'll count the number of incidents against those problems, look at the age of those incidents (i.e. is it an old issue no longer recurring, is it an ongoing issue, or is it getting worse), the resolution time (was it a quick fix or did it take a while), and calculate a score based on this to help us prioritise which problems to focus our efforts on; i.e. so we fix the PRBs which are costing our team the most time to resolve, or making our incident numbers high and thus making our stats look bad.