Forum Discussion

morciani's avatar
morciani
Occasional Contributor
15 years ago

Referencing properties inside a DataGen Test Step

Hello,

Is there a way to reference properties from within a DataGen Test step?  I want to be able to conditionally set the value of a second property based on the value of the first property. Both properties are contained in the same DataGen step (DataGen_getGlobalData) Take this example of this Test Step:

Test Step Name: DataGen_getGlobalData

Property1: SignOnRoleCd (Type = Script, Mode = STEP, not Shared)

Configuration:
import javax.swing.*
String SignOnRoleCd=JOptionPane.showInputDialog("SignOnRoleCd: Agent or Customer");

Property2: PIN ((Type = Script, Mode = STEP, not Shared)

Configuration:
if (#SignOnRoleCd == "Customer")
{
String PIN = "N0000000"
} else {
String PIN=JOptionPane.showInputDialog("PIN");
}

How do I reference SignOnRoleCd within the configuration of Property2?

1 Reply

  • morciani's avatar
    morciani
    Occasional Contributor
    I figured this one out, context.expand('${#PropertyName}') is the syntax I was looking for.

    import javax.swing.*
    def SignOnRoleCd = context.expand( '${#SignOnRoleCd}' )
    if (SignOnRoleCd == "Customer")
    {
    String PIN = "N0000000"
    } else {
    String PIN=JOptionPane.showInputDialog("PIN");
    }