HMT
HMT

Reputation: 2261

How to fetch value from property file when my key is a dynamic in mule?

I am trying to fetch value from the properties file

"mykey" = "value"
"mykey1" ="value2"

in mule, we can fetch the value by ${mykey}, but what if mykey is stored in a variable named keyName. I tried fetching the value by writing ${(#vars.keyName)} . But it is not working

Upvotes: 2

Views: 2031

Answers (3)

user3078986
user3078986

Reputation:

You should be using Mule::p, just p could get deprecated in the future.

%dw 2.0
output application/java
var myPropName = "test"
---
Mule::p(myPropName)

Upvotes: 1

Amit Jha
Amit Jha

Reputation: 11

You can use #[p(vars.keyName)] to retrieve value for key stored in variable keyName from a property file.

Upvotes: 1

Sébastien Colas
Sébastien Colas

Reputation: 424

You can use the p function: https://docs.mulesoft.com/mule-runtime/4.2/dw-mule-functions-p

p('mykey')

Upvotes: 0

Related Questions