can we get which table the glide record is pointing to?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 11:42 AM
Hi,
Can we user gr.sys_class_name before a insert, just for debug purposes?
Thanksm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 11:58 AM
Can you post the code you are looking to use? I'm a little lost on your question because in order to do an insert you would need to provide the table name you are inserting to, so you already know which table you are inserting to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 12:01 PM
Use getTableName() API
Here is a sample code.
var gr = new GlideRecord('incident');
gr.addQuery();
gr.query();
gs.print(gr.getTableName())
Let me know if you need more information.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 12:12 PM
I'm missing something - why do you need to know what table the GlideRecord object "gr" is pointing to - you are telling the system in your first line of code it is pointing to Incident. If you were using a variable instead of a table name, you would just use that variable later on in your code as well.
sys_class_name is just a value on a record that is used when you have extended tables (CMDB_CI, TASK, etc.). You would not be able to retrieve this value BEFORE an insert because it is a value you would set during your insert. For example, you would insert into CMDB_CI and set the sys_class_name to cmdb_ci_windows_server (or whatever class you are looking to insert).
If you were inserting right into CMDB_CI_WINDOWS_SERVER then the sys_class_name is the same as the table name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2016 07:53 AM
yes we tell the system at the upfront, but for some reason, I am thinking it is pointing to some other table, because we are assigning some values to the GlideRecord.
Trying gr.getTableName()