Get a GlideRecord column by its label
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 04:45 PM
Hi folks,
I have 2 tables similar columns that I want to copy from one to the other, but they only have the same label and not the name
For example:
table: cmdb_model
column: u_rpm
column label: RPM
u_hardware
column: u_en_rpm
column label: RPM
Is there a way to dynamically refer to those fields by matching the column labels?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 05:02 PM
Hi Nam,
I wouldn't. There's no way to ensure you've got the right column. The column label is a related list to the column itself and supports multiple languages.
Can you provide more detail about what you are copying and when? What's the underlying requirement/use case here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 05:13 PM
hi Chuck,
so on my set up there is a base model with parameters stored in the cmdb model table, which can be changed on the CI (for example, a laptop model that has a 8GB RAM base model, but another 8GB can be added on the CI of the same model)
Because of my ignorance when the tables were created, the columns don't have the same internal names (only talking about custom columns)
Now I'm trying to set those parameters on CI to that of the base model if they're not populated on import hence the need to refer to the field labels
What would you recommend?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 05:52 PM
Hi Nam,
Thanks for the clarification.
When you import, you can set up your import set to map the fields in the transform map. That's where it identifies "information from X gets saved to Y". Underneath, it's doing what it needs to. You don't need to do the lookups by label.
http://wiki.servicenow.com/index.php?title=Importing_Data_Using_Import_Sets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 08:16 PM
Thanks Chuck,
I couldn't find a way to apply a transform map to move data from model to hardware table, ended up putting a transform script to look up the tables and build the map variable onStart, then refer to it on each onAfter
Cheers