Check if property exist in Record Manipulator

  1. Home
  2. Blog
  3. Check if property exist in Record Manipulator

Check if property exist in Record Manipulator

Many times there is requirement to check if a property exist or not and based on that perform some logic or the other in the pipeline.

In this example we are going to create a Record Manipulator which check

  • Existence of property “demoProperty” and if it does not exist create one.
  • Else if “demoProperty” is empty add a default value to it.

Below is what we need to add to our Record Manipulator

<EXPRESSION TYPE="VOID" NAME="IF"> 
  <EXPRESSION TYPE="INTEGER" NAME="MATH">
    <EXPRNODE NAME="TYPE" VALUE="STRING"/> 
    <EXPRNODE NAME="OPERATOR" VALUE="EQUAL"/> 
    <EXPRESSION TYPE="INTEGER" NAME="PROP_EXISTS">
      <EXPRNODE NAME="PROP_NAME" VALUE="demoProperty"/> 
    </EXPRESSION>
    <EXPRESSION TYPE="INTEGER" NAME="CONST"> 
      <EXPRNODE NAME="VALUE" VALUE="0"/>
    </EXPRESSION> 
  </EXPRESSION>
  <EXPRESSION NAME="CREATE" TYPE="VOID">
    <EXPRNODE NAME="PROP_NAME" VALUE="demoProperty"/> 
    <EXPRESSION NAME="IDENTITY" TYPE="PROPERTY">
      <EXPRNODE NAME="PROP_NAME" VALUE="demoValue"/>
    </EXPRESSION> 
  </EXPRESSION>
  
  <EXPRNODE NAME="ELSE_IF" VALUE=""/> 
  <EXPRESSION TYPE="INTEGER" NAME="MATH">
    <EXPRNODE NAME="TYPE" VALUE="STRING"/> 
    <EXPRNODE NAME="OPERATOR" VALUE="EQUAL"/> 
    <EXPRESSION TYPE="PROPERTY" NAME="IDENTITY">
      <EXPRNODE NAME="PROP_NAME" VALUE="demoProperty"/> 
    </EXPRESSION>
    <EXPRESSION TYPE="STRING" NAME="CONST"> 
    <EXPRNODE NAME="VALUE" VALUE=""/>
    </EXPRESSION> 
  </EXPRESSION>
  <EXPRESSION NAME="UPDATE" TYPE="VOID">
    <EXPRNODE NAME="PROP_NAME" VALUE="demoProperty"/> 
    <EXPRESSION NAME="IDENTITY" TYPE="PROPERTY">
      <EXPRNODE NAME="PROP_NAME" VALUE="demoValue"/> 
    </EXPRESSION>
  </EXPRESSION> 
</EXPRESSION>

 

 

Let's Share
Show Buttons
Hide Buttons