cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted
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
Highlighted
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

Highlighted
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

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
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

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
Highlighted
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");
}

Highlighted
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");
}

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!