Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
527 views

TruClient - Parameters - How to add an incrementor in scripting

I want to create multiple file like Test1, test 2, test 3 etc

var currentDate =d.getFullYear().toString()+ ('0' + m).slice(-2).toString()+ ('0' + d.getDate()).slice(-2).toString();
var currentTime = ('0' + d.getHours()).slice(-2).toString() +('0' + d.getMinutes()).slice(-2).toString() +('0' + d.getSeconds()).slice(-2).toString();
var parameterName="Test_" + currentDate + "_"+ currentTime

This sometimes creating with same date n time also . I want to add an incrementor whenver it  generates.

like Test_1_CurrentDate:CurrentTime

could anyone suggest me how to add an incrementor

 

0 Likes
1 Reply
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: TruClient - Parameters - How to add an incrementor in scripting

Hi,

Not sure I understand what you are trying to do. According to your code the outcome is supposed to Test_CurrentDate_CurrentTime and not Test_1_CurrentDate:CurrentTime

If you wish to add an incrementor you can intiialize a global variable at the beginning of the script run in the Init section and then increment it before any use.

Initialization in the Init section should be done in Evaluate JavaScript step like that

Global.incrementor = 0; // No need in var definition before using the Global object

Increment the value before use in the Actions section in Evaluate JavaScript step like that

Global.incrementor++;

(See another example in TruClient help center)

You can then concatenate the value as follows

var parameterName="Test_" Global.incrementor + "_" + currentDate + "_"+ currentTime

Regards,

Shlomi

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.