Solved

XML - Latest Record

  • 17 April 2023
  • 2 replies
  • 112 views

Userlevel 1
Badge +5
  • Sidekick (Customer)
  • 11 replies

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>

icon

Best answer by Shneor Cheshin 18 April 2023, 01:31

View original

2 replies

Userlevel 6
Badge +26

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!

Userlevel 1
Badge +5

@Shneor Cheshin thank you it worked! 

Reply