Ask a Question

Parameterize the context.expand to have dynamic value

SOLVED
sanathkd
Occasional Contributor

Parameterize the context.expand to have dynamic value

Hello all,

 

I'm trying to parameterize a context.expand and re-use the same method for various properties like below.

But the "value" seems not taking properly. 

Spoiler
def logRef = propertyRead (logRef);
def user = propertyRead (user);
//-----------------------------------------------------
public static String propertyRead(String value)
{
          def newValue = context.expand( '${Properties#{$value}}' );
          return newValue;
}

Anyone to guide me here?

 
1 REPLY 1
sanathkd
Occasional Contributor

It is solved now 😃 I figured it out myself. The script helped me: 

def propertyStepName = "Properties";

propertyRead(propertyStepName, "logRef");

propertyRead(propertyStepName, "user");

 

public void propertyRead(String propertyStepName, String value){

     def newValue = context.expand('${'+propertyStepName+'#'+value+'}');

}

 


@sanathkd wrote:

Hello all,

 

I'm trying to parameterize a context.expand and re-use the same method for various properties like below.

But the "value" seems not taking properly. 

Spoiler
def logRef = propertyRead (logRef);
def user = propertyRead (user);
//-----------------------------------------------------
public static String propertyRead(String value)
{
          def newValue = context.expand( '${Properties#{$value}}' );
          return newValue;
}

Anyone to guide me here?

 

cancel
Showing results for 
Search instead for 
Did you mean: