Getting a table name from a reference field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2013 03:34 AM
I am writing a bit of script which depending on the circumstances could reference 2 different tables.
to keep it tidy and avoid writing multiple glide records I'd like to grab the table name from a reference field and then use it to point the glide record to the correct table.
Example is below:
//gets the last entry from the work notes journal and copies it to the parent request/request item
if (current.parent.getTableName() == 'sc_req_item'){
var table = 'sc_req_item';}
else{
var table = 'sc_request';
}
var rec = new GlideRecord(table);
rec.addQuery('sys_id', current.parent);
rec.query();
while (rec.next()) {
var wrk = current.work_notes.getJournalEntry(1);
rec.work_notes = wrk;
rec.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2013 04:10 AM
How about this?
current.parent.getRefRecord().getTableName()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2013 04:49 AM
Excellent Thanks Mark
I was just missing that final piece of the puzzle