Addressing Variable

Hi All,

Kindly clarify the below query.

This is just for learning purpose.

I have a document list “InputList” and it contains 5 values.

I want to select a random value from DocumentList without loop.

The DocumentList position will come from input as “pos”.

I have tried like,
and both are not giving output value.

Kindly help me to resolve this.

Thanks in advance.

Hi Charles,

You have to:

  • create a mapping from the documentList to your target document
  • click on the mapping (the actual line)
  • on the Properties view you will see an Indices property
  • there click on the “…” button and edit the Row Index field


Hi Vlad,

Thanks for your reply.It’s working .

but why these two are not working,

webMethods is substituting the pipeline variable value which is inside the percentage symbol(%) .

1.%InputList[pos]% ==InputList[0] //pos=0
2.%InputList[%pos%]%==InputList[0] //pos=0

Can I know the reason for this?

Hi Charles,

I can only assume that the variable substitution algorithm simply extracts the variable names from the %…% expression and searches for them on the pipeline.

In your case InputList[pos] is not a variable name. InputList and pos are, but not InputList[pos].

The second example (%InputList[%pos%]% ) can also be read differently.
Two variables %InputList[% and %]% with the pos string in the middle

Again, this is only an assumption, I haven’t checked in detail the documentation.


1 Like

Hello Charles,

If I understand your requirement correctly you have a input say inputItemList which will be a string list and you have to select a random value from this list

INPUT: inputItemList= {1,2,3,4,5}
OTUPTU: item=2 or 3 or 4 or random value

This can be easily done writing a java code.

Hi Vlad,

Thanks for your reply .

Thanks Mahesh.

I have little knowledge on java to resolve this.

Vlad explained clearly,I guess webMethods considers as a single variable whatever value in between %%.

Is there any way to substitute two pipeline variable in a map step like %InputList[pos]%.

Hi Charles,

you need to do a multi-layered substitution for this.
check the substituteVariables code from PSUtilities package.

Even I tried in the past to get the Multi-variable substitution like the one. But I could not get the solution.

The only way I know of is to either use java service or Loop within the flow service.

Even I am excited to see if Multi-layered substitution is possible within the flow service.