Dynamically change column name in Project Variables
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dynamically change column name in Project Variables
Is it possible to create table with dynamic column names. I have below code:
Set ti = Project.Variables.VariableByName("MyTable")
ti.AddColumn("Name")
ti.RowCount = 1
Project.Variables.VariableByName("MyTable").Name(0) = "ABCD"
instead of passing "Name", I need to pass variable, like below
colName = "Name"
ti.AddColumn(colName)
Project.Variables.VariableByName("MyTable").colName(0) = "ABCD"
Above code returns "undefined" error.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The reason being is that colName needs to be evaluated. "colName" is not the name of the column so you can't set the value.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You want to use the item property of the table variable to get it by name.
See https://support.smartbear.com/testcomplete/docs/reference/program-objects/tablevariable/item.html
Thanks,
Carson
Click the Accept as Solution button if my answer has helped
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't think you can update/rename the existing column name.
Is there any reason why would you rename the Column?
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@shankar_r I don't think he wants to rename after it's created, but have a way to create the table without a specified name.
Thanks,
Carson
Click the Accept as Solution button if my answer has helped
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks guys for your response. I am creating table on fly and need to use column name as per the passed argument. I am able to resolve the issue now.
Thanks.
