HomeSUPPORT QUESTIONS

Need help with StresStimulus? Start here.

Conditional Loop based on the Dataset Messages in this topic - RSS

nee2_020
nee2_020
Posts: 1


22 days ago
nee2_020
nee2_020
Posts: 1
Hi,

I am new to SS.

I am trying to create an if..else conditional loop based on a value from a dataset instead of an extractor.

Can you please help me with this.

Thank you
0 link
George @StresStimulus
George @StresStimulus
Administrator
Posts: 302


22 days ago
George @StresStimulus
George @StresStimulus
Administrator
Posts: 302
In order to accomplish you can create a scriptable variable that would read the dataset and return “true” or “false” based on your required condition.

To create a scriptable variable you need to implement the IExternalVariable.GetValue() method and to access a dataset use the SessionContext.GetDatasource() method.

For example:

using System;
using StresStimulus.Extensibility;
using System.Data;

class ExternalCondition : IExternalVariable
{
public ExternalCondition()
{
//Do not edit this section.
}

#region IExternalVariable Members

/// <summary>
/// Return true if the variable will be evaluated once per VU iteration. Otherwise will be evaluated on every parameter.
/// </summary>
bool IExternalVariable.EvaluateOnIteration
{
get
{
return true;
}
}

/// <summary>
/// Return a value for the given session context.
/// </summary>
/// <param name="session">The session context object of the request consuming the variable.</param>
/// <returns>The source variable value.</returns>
string IExternalVariable.GetValue(SessionContext context)
{
DataTable dt = context.GetDatasource("{Your dataset name}");

return
((string)dt.Rows[context.VUNumber ]) == "xxxxxxxxx" ? //get the row associated the a VU
"true" :
"false";
}

#endregion
}

Then when creating a Condition (http://support.stresstimulus.com/display/doc52/If...Then) set the following properties:
1. Condition type property to Match scriptable variable
2. Scriptable variable to match property to Name of the scriptable variable.
3. Text-to-match property to "true"




- Cheers
0 link






Copyright © 2020 Stimulus Technology