Increment a variable value per block
search cancel

Increment a variable value per block

book

Article ID: 16990

calendar_today

Updated On:

Products

CA Agile Requirements Designer

Issue/Introduction

We would like to be able to increment a variable by one on demand. This variable is assigned to the flow (set to zero). For certain blocks, it needs to be incremented. This will need to be done by a test data entry. We have tried a VAR = "@add(VAR,1), but we get a referencing error. Also next, nextval, etc. all seem to not do what we need. There are flow attributes that increase based on blocks and automation, but we wish to control which blocks add to the variable. Do you have any ideas on how to achieve this?

Environment

CA Agile Requirements Designer (ARD)- Agile Designer

Resolution

We suggest using Nextval with a specific sequence name. You need to set it up so that each assignment remains.


For example, if you assign three blocks like so:

Block A -> [email protected](Sequence)@ 
Block B -> [email protected](Sequence)@ 
Block C-> [email protected](Sequence)@ 

Then the test data variable at the end will consist only of one variable, 'Count', which will then increment the sequence exactly once. This way you are just overwriting count three times here without executing the Nextval. 

 

Alternatively, you could do this:

Block A -> [email protected](Sequence)@ 
Block B -> [email protected](Sequence)@ 
Block C-> [email protected](Sequence)@ 

OverallCount = @Nextval(Sequence)

With this approach, all will be resolved, but you need OverallCount to be resolved last, so you will need to ensure that a reference to count1,count2,count3 would help. For example, bring them into the expression but take a 0 length substring of them.

 

The root of this problem is that all test data is calculated at the end, so you can't increment a variable like i++.

However, you can take the sum of a static set of variables, which all default to 0, but are set to 1 if a specific block is reached. If you cannot use a sequence, this would be the approach to take.

Additional Information

If you experience any issues, please open a support case by going to https://support.broadcom.com