Recursive Variable Sustitution

Hello All,

I have a requirement to recursive substitute variable names in webmethods. I have 2 variables

  1. Variable1 = ‘John’

  2. Variable2 = ‘Variable1’

Now I want to put like %%Variable2%% , which should result ‘John’. I tried variableSubstitute service from PSUtilities but its not working for me.

Does anyone have any approach to get rid of above issue.

Thanks
Kapil

If you change this

to this Variable2 = %Variable1% and use %Variable2% anywhere after in the flow, it will result in ‘John’.

Hello Suren,

Thanks for your reply but my problem is

field1 = ‘field2’ (this is a text)
and field2= ‘john’

and name of field2 is variable the only way to get name of second field is from field1 … I have tried several ways but not working. Could you please guide me …with some suggestions.

Regards
Kapil

For your scenario, don’t worry about variable substitution. You can do what you need with a simple Java service. E.g.:

This service takes an input string called ‘key’ and returns a string called ‘value’. ‘key’ is the name of the variable whose value you want and ‘value’ is that value.

As you can imagine, true nested substitution would be extremely challenging using percent signs only (or any single character) because, for example, you could have a scenario such as %a%b%c% which could mean different things, like + ‘b’ + or <value of <‘a’ + + ‘c’>>

If you make an assumption that nested substitution will always take the simplistic form of %%variable%% … %%%%%variable%%%%%, you should be able to easily write your own service using the PSUtilities code and the code above as a reference.

Good luck,
Percio

Hello Percio,

It did work for me…thanks a lot for your help.

Regards
Kapil