1

I have properties as below

path.order=/order
path.address=/address

Usually we will use ${path.order} to get the key value. I want to pass the type(order or address) dynamically to get the key value. Like below

${path.#[flowVars.type]}

I tired with above expression. It did not work. can you please help on this to prepare and get the key dynamically

Gopi
  • 105
  • 1
  • 7
  • 24

4 Answers4

0

Your requirement can be achieved using dataweave function. I am posting a snippet. I tried concatenating withing the final dw expression, but it didn't work. Let me know if this fulfills your requirements.

<message-properties-transformer scope="invocation" doc:name="Message Properties">
            <add-message-property key="type1" value="address"/>
            <add-message-property key="type2" value="object"/>
        </message-properties-transformer>
<message-properties-transformer scope="invocation" doc:name="Message Properties">
     <add-message-property key="property1" value="#['path.' + flowVars.type1]"/>
     <add-message-property key="property2" value="#['path.' + flowVars.type2]"/>
        </message-properties-transformer>
<logger message="#[dw('p(flowVars.property1)')]" level="INFO" doc:name="Logger"/>

I have written a post on this here, as well.

Abhay Singh
  • 170
  • 5
0

I have a dictionary defined in my variables

var.dictionary=#[['key':'value', 'key': 'value']]

Then in my Dataweave I reference it and pass a key to it

node: flowVars.var.dictionary[payload01.key]

So (unfortunately untested) your example should have a variable:

var.dictionary=#[['order':'/order', 'address': '/address']]

And reference it as

flowVars.var.dictionary[#[flowVars.type]]

So it should look like:

<logger message="#[path.#flowVars.var.dictionary[#[flowVars.type]]]" level="INFO" doc:name="Logger"/>
0

Access .property file by inserting following code.

<context:property-placeholder location="smtp.properties"/>

And Use it like this.

<logger message="${propertyFromFile}" doc:name="System Property Set in Property File"/>

https://www.youtube.com/watch?v=D95iw_ny8J4

Hemin
  • 712
  • 1
  • 14
  • 29
0
<set-variable variableName="type" value="order" doc:name="Variable"/>

    <expression-component doc:name="Expression"><![CDATA[flowVars.propertyName='path.'+flowVars.type;
    flowVars.propertyValue =dw("p(flowVars.propertyName)");]]></expression-component>

<logger message="#[flowVars.propertyValue]" level="INFO" doc:name="Logger"/>
user3366906
  • 149
  • 2
  • 11