0


New to Mule4 and have a question. I am posting a simple xml file using postman

<cust>
  <act>1234</act>
</cust>

In my flow I have
Listener->TransformMessage->logger
Inside TransformMessage I have the following:
Added a new target called f1 as variable

%dw 2.0
output application/java
var myXML = payload
---
{
    f1: myXML.cust.act
}

And in the logger I am printing the value using #[vars.f1] and the output I am getting is {f1=1234} which is right.
So my question is how can I only get the value “1234” out of it? Reason is let says I want to use this in a query, for example

Select name, address from account where accountNumber = ':vars.f1'
Thanks

borna
  • 906
  • 3
  • 12
  • 32

1 Answers1

3

The problem is that you are wrapping the result in an object with a field f1

%dw 2.0
output application/java
var myXML = payload
---
{
    f1: myXML.cust.act
}

So what you should do is just return the value like

%dw 2.0
output application/java
var myXML = payload
---
myXML.cust.act
machaval
  • 4,969
  • 14
  • 20
  • Thank you. Well that works if I add #[payload.cust.act] in the logger. Then I get 1234. However how can I add that to a variable ? – borna Jun 28 '19 at 19:14
  • You can use the `set-variable ` – machaval Jun 28 '19 at 19:41
  • even set-variable not working. it seems f1 IS based on key/value. is there a way to assign the value of that key to a variable? – borna Jun 28 '19 at 22:35