1

I have groovy transformer component which is to get the inbound properties and set it in the flow vars as like below.

if(message.inboundProperties.'http.query.params'.Brand != null){
    flowVars ['Brand'] = message.inboundProperties.'http.query.params'.Brand
}
return payload;

But I am getting below specified error. It seems inboundProperties are not in the scope of groovy. Can you please tell me how to access inbound properties in groovy.

Note : I dont want to alter the payload. My aim is to create the flowVars based on queryparms.

Part of Error :

No such property: inboundProperties for class: org.mule.DefaultMuleMessage (groovy.lang.MissingPropertyException)
  org.codehaus.groovy.runtime.ScriptBytecodeAdapter:51 (null)
Julian Mann
  • 6,256
  • 5
  • 31
  • 43
Simbu
  • 766
  • 1
  • 12
  • 37

3 Answers3

4

I can't see a getInboundProperties() method on DefaultMuleMessage

I'm guessing you want:

if(message.getInboundProperty('http.query.params')?.Brand){
    flowVars ['Brand'] = message.getInboundProperty('http.query.params').Brand
}
tim_yates
  • 167,322
  • 27
  • 342
  • 338
1

You have two options to set the variable from inbound properties:

  1. Replace the groovy component with MEL, replace <scripting:component doc:name="Groovy"> with <expression-component doc:name="Expression">
  2. Keep using groovy component, then modify the existing code

    if(message.getInboundProperty('http.query.params').get('Brand') != null) {
    flowVars ['Brand'] = message.getInboundProperty('http.query.params').get('Brand');
    }
    return payload;
    
sulthony h
  • 1,279
  • 1
  • 8
  • 9
1

Use message.getInboundProperty.

def brand = message.getInboundProperty('http.query.params').Brand
if (brand != null){
    flowVars ['Brand'] = brand
}
return payload;
tbriscoe
  • 160
  • 1
  • 13