How to find the table name using Sys_id of a form value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2016 03:51 AM
Hi All,
I want the table name of the record based on sys_id
i have tried below code in query business rule before , its not working
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var ci_sysid = current.cmdb_ci.sys_id;
var gr = new GlideRecord('sys_db_object');
gr.addQuery('sys_id',ci_sysid);
gr.query();
while(gr.next())
{
gs.addInfoMessage(gr.name);
}
})(current, previous);
please help
Thanks
Bhoomika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2016 06:32 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2016 06:35 AM
You commented out the critical parts the template gives you. The entire script should include:
answer = ifScript();
function ifScript() {
if (current.cmdb_ci) {
if (current.cmdb_ci.used_for) {
if (current.cmdb_ci.used_for == 'production') {
return 'yes';
}
}
}
return 'no';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2016 05:34 AM
Hi Bhoomika,
workflow will run on sc_req_item table, if you write like that means it will not work out.
You need to glide record on that chenge request table, then you can verify that condition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2016 05:51 AM
Hi Bhoomika,
If you want to get current table name current.cmdb_ci.getTableName().
For Reference field table name, example field name is configuration item current.cmdb_ci.sys_class_name.
Code: gs.addInfoMessage(current.cmdb_ci.sys_class_name);
Output:
- Mansoor
PS - Please mark Helpful, Like, or Correct Answer if applicable.