Hi @MartinF,
I’d go down the xpath XML here.
Not sure what your output would be, but doing a hierarchy select using the task_id to obtain the request_id would do it.
An example below. Using the task_id the output would then create an event on request_event. In theory you could do the select straight from the Task table.
Hope this helps
Ady
<perform_batch>
<hierarchy_select result_name="select_task_attachment01" max_rows='1'>
<attrs>
<attr>task_attachment.task_id</attr>
<attr>task.request_id</attr>
</attrs>
<primary_table>task_attachment</primary_table>
<from>
<table>task_attachment</table>
<table>task</table>
</from>
<where>
<join_constraint>
<constraint>
<left_operand>task_attachment.task_id</left_operand>
<operator>eq</operator>
<right_operand>task.task_id</right_operand>
</constraint>
</join_constraint>
<data_constraint>
<constraint>
<left_operand>task_attachment.task_id</left_operand>
<operator>eq</operator>
<right_operand>@task_id</right_operand>
</constraint>
</data_constraint>
</where>
</hierarchy_select>
<update_request_event>
<request_event>
<request_id xpath_node="//task_attachment_hierarchy_select_resulte@result_name='select_task_attachment01']/task_attachment/task/request_id"/>
<event_type>ADD EVENT TYPE</event_type>
<insert_update />
</request_event>
</update_request_event>
</perform_batch>
With the existing parent join from task_attachment to task (metadata), I believe the expression would work too, and less strenuous than the hierarchy select.
try this:
<update_request_event>
<request_event>
<request_id>@expressionstask.request_id]</request_id>
<event_type>ADD EVENT TYPE</event_type>
<insert_update />
</request_event>
</update_request_event>
Hi @AdrianEgley,
Thanks for your prompt response. I tried your XML code and it indeed worked a treat!
Hi @Rwjgoedhart,
Thanks also for your reply! ...i have a question however: usually the parameters would be passed in like this » @task_id -so how does it resolve the ‘@expressionetask.request_id]’ how does this expression know which task it is looking at?
@MartinF That’s great.
I’m also interested to try the way @Rwjgoedhart mentioned, if that works it maybe a few Business Rules i’ll look to update too.
Ady
in my experience, the expression in XML seems to be able to grab data that is defined in Joins in Metadata. we use this very successfully on various XML Rules today.
What the exact function behind it is… no idea. I don’t remember how/where I learned the trick, and unfortunately, the Documentation is of not much help.
It has worked very well for us in the past though, both in Workflow scripting and Business rules, it seems to associate to the right records through the joins.
-Rudy
@Rwjgoedhart@AdrianEgley
Just tested Rudy’s implementation and it works great too, ill be going with that one as its much simpler. Adrians solution was also very helpful as it has helped explain a bit more about how these things work.
Thanks again guys.