Skip to main content

Using XML, is there a way to grab the latest record? In the below example, there are multiple “OPEN” records associated with the task_id but I would only want the latest record. Also is there a resource to learn more about XML and FSM?

 

 <data_constraint>
        <constraint>
          <left_operand>task_event.task_id</left_operand>
          <operator>eq</operator>
          <right_operand>@task_id</right_operand>
        </constraint>
        <constraint>
          <left_operand>task_event.event_type</left_operand>
          <operator>eq</operator>
          <right_operand>OPEN</right_operand>
        </constraint>
      </data_constraint>

Hey @qquac 

What is the latest?

You can add an order by clause after the where.

For example

  <order_by>
<desc>task_event.modified_dttm</desc>
</order_by>
<hierarchy_select result_name="MyResult01" max_rows="1">
<primary_table>task_event</primary_table>
<attrs>
<attr>task_event.task_id</attr>
<attr>task_event.modified_dttm</attr>
<attr>task_event.created_dttm</attr>
</attrs>
<from>
<table>task_event</table>
</from>
<where>
<data_constraint>
<constraint>
<left_operand>task_event.event_type</left_operand>
<operator>eq</operator>
<right_operand>OPEN</right_operand>
</constraint>
</data_constraint>
</where>
<order_by>
<desc>task_event.modified_dttm</desc>
</order_by>
</hierarchy_select>

 

Cheers!


@Shneor Cheshin thank you it worked! 


Reply