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 05:28 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2016 05:33 AM
Red means there is an error somewhere in the script. Hover over the activity on the workflow and see what it says. My code was meant as a sample and may require updates. I don't know what your choice values are for used_for. It is more likely 'Production', but that does not dismiss the error. You need to find out what that is first. Check the workflow logs, check under System Logs> Logs> Error (and Warning.) See what turns up there. It could be a stupid mistake on my part.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2016 05:39 AM
No actually the problem is that used_for field is not available on cmdb_ci table. For example it is available in service_offering, business_service some tables like this.And the records of these tables are also available under cmdb_ci.
This is the main problem where i got stuck and not getting how to resolve exactly.
I will check the logs as well.
Regards,
Bhoomika

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2016 05:43 AM
You could always check for the field before using it...
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:54 AM
Same error in the workflow.
Regards,
Bhoomika