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

shill
Mega Sage

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?

5 REPLIES 5

How about



var z = 5;


var x = y.toString();


gr.setValue(x, z);



instead....