cancel
Showing results for 
Search instead for 
Did you mean: 

Testcomplete-Desktop Application-How to get the ID of newly created record?

New Contributor

Testcomplete-Desktop Application-How to get the ID of newly created record?

I am new to TestComplete and have an issue in which a new record is being added to the system using a winform application but I am not sure how to get the ID for the new record so that it can be used in other test steps to update/delete the same record. 

 

NOTE: I am using keyword test to automate my application

5 REPLIES 5
Contributor

Re: Testcomplete-Desktop Application-How to get the ID of newly created record?

@sanjini  try using the  index method

 

here is the link https://support.smartbear.com/testcomplete/docs/reference/project-objects/items/network-suite/task/i...

 

regards

SivaKartheek Sreeram

Community Manager

Re: Testcomplete-Desktop Application-How to get the ID of newly created record?

Hi @sanjini,

 

According to the screenshot, you are working with a grid  - to get the target number you will need to access a specific cell of the grid. I recommend that you read the Common Operations for Grids articles to learn how to do this:

https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/grids/common-operations.h...

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Community Manager

Re: Testcomplete-Desktop Application-How to get the ID of newly created record?

Hi @sanjini,

 

Did you find a solution? Please share it with us.

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Contributor

Re: Testcomplete-Desktop Application-How to get the ID of newly created record?

If you are aware of the Column value name, use this function to get the Row Index

 

ClickGrid(GRID-Parentobject of TCXGRIDSITE,  Column Name, Value-New value which are creating from Testcomplete) Return this function, you will get the row index for the same.

 

function ClickGrid(Grid,Column,Value)
{
var RowIndex;
function FindRow(Grid, Column, Value, ViewId)
{
if (typeof(ViewId) == "undefined")
ViewId = 0;
for (var i=0; i<Grid.wRowCount(ViewId); i++)
if (Grid.wValue(i, Column, ViewId) == Value)
return i;
return -1;
}
RowIndex = FindRow(Grid,Column,Value);
if (RowIndex != -1)
{
Grid.ClickCell(RowIndex, Column);
Log.Message("Row index: " + RowIndex + " Column Name: " + Value);
}
else
Log.Error("Row was not found");
}

Contributor

Re: Testcomplete-Desktop Application-How to get the ID of newly created record?

updated the function with return rowindex.

 

 

function ClickGrid(Grid,Column,Value)
{
var RowIndex;
function FindRow(Grid, Column, Value, ViewId)
{
if (typeof(ViewId) == "undefined")
ViewId = 0;
for (var i=0; i<Grid.wRowCount(ViewId); i++)
if (Grid.wValue(i, Column, ViewId) == Value)
return i;
return -1;
}
RowIndex = FindRow(Grid,Column,Value);
if (RowIndex != -1)
{
Grid.ClickCell(RowIndex, Column);
Log.Message("Row index: " + RowIndex + " Column Name: " + Value);

return RowIndex
}
else
Log.Error("Row was not found");
}