Subscribe
Accepted Solution

How to concatenate a value from an array and a string to a constant or parameter

Hi everbody,

 

I have configured the following:

 

In constants section, I have configured several constants with this naming convention <location>_<purpose>, i.e. es1_gateway or es2_gateway. The value is an IP-address.

During the workflow execution the location will be discovered via a 2-d array and the function "getValueAt2D(toLower(sap_objects),1,3)".

I added "getValueAt2D(toLower(sap_objects),1,3) + '_gateway'" (without ")  in the field "RouteGateway" of "other parameters" section of the command "create logical interface".

WFA discovers all variables and constants correctly, but interprets this field as a string (es1_gateway instead of the IP-address.

 

Please see also attachments.

 

How can I achieve that the IP-address from the constants will be choosen?

 

Thanks,

Tino

Re: How to concatenate a value from an array and a string to a constant or parameter

@TiMatrix

 

WFA is behaving correct, you have assumed 'double-computation' for a string field which doesn't happen because you are computing only once. The value obtained after computing  getValueAt2D(toLower(sap_objects),1,3) + '_gateway' is not going to be re-evaluated as a constant and replaced with the value of the constant. Nope, not happening. You are trying to make constant work like a variable, which it can't.

 

So to get what you want you should give off this constant and use one of the following:

 

1. Use a MVEL expression, it works good but the expression can become complex, especially to debug.

 

(getValueAt2D(toLower(sap_objects),1,3) + '_gateway') == 'es1_gateway'? '192.1681.1' :' 192.168.1.2'

 

 

2. 

 

 

Have a function definition as below:

 

function returnIP(location)

{

 

if (location== 'es1_gateway')

   {  return '192.168.1.1';   }

if (location== 'es1_gateway')

   {   return '192.168.1.2';   }

 

}

 

 

And now do your re-computation in the field:  

 

retrunIP(getValueAt2D(toLower(sap_objects),1,3) + '_gateway' )

 

Let me know how this worked for you.

 

sinhaa

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: How to concatenate a value from an array and a string to a constant or parameter

HI sinhaa,

 

thank you for your reply. 

I will try your proposals by the end of this week, then I will have access to the WFA.

When I will have it tested, I will give feedback again.

 

Thanks,

Tino

Re: How to concatenate a value from an array and a string to a constant or parameter

Hi sinhaa,

 

I have successfully tested your proposals. These work very well. 

I have decided to use the function, because it can be reused for further use cases and easier to manage.

 

Thanks,

Tino