Ask a Question

Using Variables for Numbers that Increase

SOLVED
michelleunique
New Contributor

Using Variables for Numbers that Increase

Hello, 

 

I want to create a test that goes in to our system and tests the function of creating and saving a work order. It needs to open up a new work order and assign that work order a unique number. I believe using a variable in the work order number field is the answer, but a but stumped on how to do it. 

 

Our system won't allow a work order to be saved if it shares the same number as another that is already in the database. So,  I need a way to open a new work order, enter the number of the order created the last time the test ran +1. For instance if I run the test on Monday and it creates Work Order # 151,  when I run the same test on Tuesday, I'd like it to create work order # 152,  and on Wednesday #153, and so on for infinity. 

 

If it's possible to make suggestions keyword-test-style instead of scripting-style, that would be so much appreciated. 

 

Thanks in advance! 

 

3 REPLIES 3
rraghvani
Trusted Contributor

It can be done, providing you can gain access to the last work order number (is it visible on screen?), for you to increment later. Otherwise, you'll have to query the database to get the last work order number.

MW_Didata
Frequent Contributor

I believe you could use persistent variables, if you use +1 then the next day it should remember the value and do +1 again and so on...

They can be found here:

MW_Didata_0-1671452813196.png

 

Temporary variables will not be remembered

Marsha_R
Community Hero

As @MW_Didata said, persistent variables are the way to go. You might run into an issue if someone else is running the same test from a different TC instance or the work order gets updated some other way outside of TestComplete. If this is an issue, then you can add an If statement to check when you start to make sure that your variable value is greater than the highest one in the database, and if not, display an error.


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
cancel
Showing results for 
Search instead for 
Did you mean: