Setting a column value by using a script variable as the column name

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2014 09:43 PM
I am attempting to use a script to set the value of a column using setValue(myvariable, value)
So current is my table A, I query table B from which I pull column names for setting values in table C.
Table A has a common field with B and C.
Essentially I am trying to update table C with values from table B when table A is updated (if that makes sense).
Here is an simple example of the code I am having trouble with. It seems I cannot use a variable as the column name in my gliderecord setValue function.
The red text below is where I am having trouble setting the column to use in the second gliderecord.
var grb = new GlideRecord('table_b');
grb.query();
while(grb.next()){
var column = grb.name;
var value = grb.value;
var grc = new GlideRecord('table_c');
grc.get(field, value);
grc.setValue(column, value);
grc.update();
I have verified that the value of column is a column name in table c.
Anyone have a clue as to how I might perform this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2014 11:34 AM
How about
var z = 5;
var x = y.toString();
gr.setValue(x, z);
instead....