What is the difference between current.getTableName() and current.sys_class_name in terms of operation

sam352120
Kilo Guru

Hi All,

 

I have used both current.getTableName() and   current.sys_class_name in an existing Business to perform a specific operation .I got the desired output

by using current.sys_class_name ,But that did not work for current.getTableName().Please share your valuable inputs(practical scenario) apart from the Wiki.

 

Thanks in Advance.

13 REPLIES 13

Actually, the field "current.sys_class_name" should exist on any extended table or its children, not just Task tables.   You will see it wherever objects are extended from a base class:



  • Assets
  • CMDB
  • Credentials
  • etc.


I believe it would be there for custom tables as well, if they are extended/extensible.




Thanks,


-Brian


It works for any inherited tables, see my previous post.   In a nutshell, sys class name lets you query a parent table and get the name of the child name whereas gettablename only sees the table you are currently on.


Sorry, refresh-overlap. I had loaded the page before your reply and was reading... and THEN replied myself.  



Didn't see your post till the refresh.




Thanks for the explanation though,


-Brian


Hi Pradeep,



How can i get the table name for a custom table. As you mentioned above we cannot use getTableName of sys_class_name for a custom table. Let me know if there is any alternative for this.



Thanks


jschlieszus
Kilo Guru

Not intending to start up an old thread but the difference in output between sys_class_name and getTableName() depends on whether you are calling it on a table that is in a table hierarchy (which task is, but applies to any, custom or OOB).



If you were to query the cmdb_ci table for and print getTableName and sys_class_name for all records, getTableName would return cmdb_ci because that is the table you queried, whereas sys_class_name would return the actual record's table name if it should happen to be a child table such as application, database, etc.



*** Script: table name:cmdb_ci ------ sys class name: cmdb_ci_server


*** Script: table name:cmdb_ci ------ sys class name: cmdb_ci_network_adapter


*** Script: table name:cmdb_ci ------ sys class name: cmdb_ci_network_adapter


*** Script: table name:cmdb_ci ------ sys class name: u_fmr_cmdb_network_traffic_manager


*** Script: table name:cmdb_ci ------ sys class name: cmdb_ci_network_adapter


*** Script: table name:cmdb_ci ------ sys class name: cmdb_ci_network_adapter


*** Script: table name:cmdb_ci ------ sys class name: u_cmdb_ci_app_web_server


*** Script: table name:cmdb_ci ------ sys class name: u_cmdb_ci_phone_num


*** Script: table name:cmdb_ci ------ sys class name: u_cmdb_ci_phone_num


*** Script: table name:cmdb_ci ------ sys class name: cmdb_ci_computer


*** Script: table name:cmdb_ci ------ sys class name: cmdb_ci_computer


*** Script: table name:cmdb_ci ------ sys class name: cmdb_ci_computer


*** Script: table name:cmdb_ci ------ sys class name: u_cmdb_ci_phone_num


*** Script: table name:cmdb_ci ------ sys class name: u_fmr_patch_panels


*** Script: table name:cmdb_ci ------ sys class name: u_cmdb_ci_phone_num