Question

Mass Update for multiple rows

  • 24 January 2023
  • 7 replies
  • 154 views

Userlevel 4
Badge +11

Hi,

I am creating an xml message to update (child) tasks which have different task-status and owner(person_id) from their (visit)task.

I created a custom view to get those tasks.

In this query:

task_id = visit-task

child_task_id = task_id

 

the xml message looks like this.

<!-- =========================================================== -->
        <!-- update task owner and task status from visit when visit-owner is not empty -->
 <!-- ======================================================== -->
        <perform_batch>
            <sequential_dependent>
                <hierarchy_select result_name="select_result1">
                    <primary_table>task</primary_table>
                    <attrs>
                        <attr>task.task_id</attr>
                        <attr>task.person_id</attr>
                        <attr>task.task_status</attr>
                        <attr>task.team_id</attr>
                        <attr>c_visit_task_owner_diff_view.task_id</attr>
                        <attr>c_visit_task_owner_diff_view.visit_owner</attr>
                        <attr>c_visit_task_owner_diff_view.visit_task_status</attr>
                        <attr>c_visit_task_owner_diff_view.visit_team_id</attr>
                    </attrs>
                    <from>
                        <table>task</table>
                        <table>c_visit_task_owner_diff_view</table>
                    </from>
                    <where>
                        <data_constraint>
                            <constraint>
                                <left_operand>c_visit_task_owner_diff_view.visit_owner</left_operand>
                                <operator>not_null</operator>
                            </constraint>
                        </data_constraint>
                        <join_constraint>
                            <constraint>
                                <left_operand>task.task_id</left_operand>
                                <operator>equi</operator>
                                <right_operand>c_visit_task_owner_diff_view.child_task_id</right_operand>
                            </constraint>
                        </join_constraint>
                    </where>
                </hierarchy_select>
                <mass_update_task>
                    <hierarchy_select result_name="select_result11">
                        <primary_table>task</primary_table>
                        <attrs>
                            <attr>task.task_id</attr>
                            <attr>task.person_id</attr>
                            <attr>task.task_status</attr>
                            <attr>task.team_id</attr>
                            <attr>c_visit_task_owner_diff_view.task_id</attr>
                            <attr>c_visit_task_owner_diff_view.visit_owner</attr>
                            <attr>c_visit_task_owner_diff_view.visit_task_status</attr>
                            <attr>c_visit_task_owner_diff_view.visit_team_id</attr>
                        </attrs>
                        <from>
                            <table>task</table>
                            <table>c_visit_task_owner_diff_view</table>
                        </from>
                        <where>
                            <data_constraint>
                                <constraint>
                                    <left_operand>task.task_id</left_operand>
                                    <operator>eq</operator>
                                    <right_operand xpath_node="//task_hierarchy_select_result[@result_name='select_result1']/task/task_id"/>
                                </constraint>
                                <constraint>
                                    <left_operand>c_visit_task_owner_diff_view.visit_owner</left_operand>
                                    <operator>not_null</operator>
                                </constraint>
                            </data_constraint>
                            <join_constraint>
                                <constraint>
                                    <left_operand>task.task_id</left_operand>
                                    <operator>equi</operator>
                                    <right_operand>c_visit_task_owner_diff_view.child_task_id</right_operand>
                                </constraint>
                            </join_constraint>
                        </where>
                    </hierarchy_select>
                    <task>
                        <task_id xpath_node="//task_hierarchy_select_result[@result_name='select_result11']/task/task_id"/>
                        <person_id xpath_node="//task_hierarchy_select_result[@result_name='select_result11']/task/c_visit_task_owner_diff_view/visit_owner"/>
                        <team_id xpath_node="//task_hierarchy_select_result[@result_name='select_result11']/task/c_visit_task_owner_diff_view/visit_team_id"/>
                        <task_status xpath_node="//task_hierarchy_select_result[@result_name='select_result11']/task/c_visit_task_owner_diff_view/visit_task_status"/>
                        <update/>
                    </task>
                    <transaction_size>100</transaction_size>
                    <synchronous>Y</synchronous>
                </mass_update_task>
            </sequential_dependent>
        </perform_batch>

 

That message can update only the 1st row of those result.

How can I update all the results?

 

@Saranga Amaraweera , you mentioned in my previous post about this post

This post is only for IFS employees and partners.  Could you please post it here?  Thanks in advance.

 

Look forward to your feedback.

 

Cheers,

~Juni


7 replies

Userlevel 6
Badge +26

Sorry, got this wrong.

Cheers!

Userlevel 4
Badge +11

the “select_result1” hierarchy select returns correct result:

<task_hierarchy_select_result result_name="select_result1">
  <task>
    <metrix_row_num>1</metrix_row_num>
    <person_id>GGASSELING</person_id>
    <task_id>2419</task_id>
    <task_status>PLANNING</task_status>
    <team_id>00301008_REGION_WEST</team_id>
    <c_visit_task_owner_diff_view>
      <metrix_row_num>1</metrix_row_num>
      <child_task_id>2419</child_task_id>
      <task_id>2420</task_id>
      <visit_owner>DVANROOIJ</visit_owner>
      <visit_task_status>IN PROCESS</visit_task_status>
      <visit_team_id>00301008_REGION_WEST</visit_team_id>
    </c_visit_task_owner_diff_view>
  </task>
  <task>
    <metrix_row_num>2</metrix_row_num>
    <person_id>PHEGEMAN</person_id>
    <task_id>3415</task_id>
    <task_status>PLANNING</task_status>
    <team_id>00301008_REGION_ZUID</team_id>
    <c_visit_task_owner_diff_view>
      <metrix_row_num>1</metrix_row_num>
      <child_task_id>3415</child_task_id>
      <task_id>3416</task_id>
      <visit_owner>DVANROOIJ</visit_owner>
      <visit_task_status>IN PROCESS</visit_task_status>
      <visit_team_id>00301008_REGION_WEST</visit_team_id>
    </c_visit_task_owner_diff_view>
  </task>
  <task>
    <metrix_row_num>3</metrix_row_num>
    <person_id>DVANROOIJ</person_id>
    <task_id>12966</task_id>
    <task_status>PLANNING</task_status>
    <team_id>00301008_REGION_WEST</team_id>
    <c_visit_task_owner_diff_view>
      <metrix_row_num>1</metrix_row_num>
      <child_task_id>12966</child_task_id>
      <task_id>13003</task_id>
      <visit_owner>MADISP</visit_owner>
      <visit_task_status>PLANNING</visit_task_status>
      <visit_team_id>00301008_REGION_ZUID</visit_team_id>
    </c_visit_task_owner_diff_view>
  </task>
</task_hierarchy_select_result>

Userlevel 4
Badge +11

Hi @Shneor Cheshin ,

I just updated the post with the mass-update message. 

Copied/pasted wrong message before. :-)

Userlevel 4
Badge +11

@Shneor Cheshin ,

could you please post this (https://community.ifs.com/ifs-field-service-management-fsm-employees-partners-only-103/hierarchy-select-with-mass-update-10528) convesation here? 

 

Thanks in advance,

~Juni

Userlevel 6
Badge +26

Hi @Shneor Cheshin ,

I just updated the post with the mass-update message. 

Copied/pasted wrong message before. :-)

😂

Userlevel 6
Badge +26

@Shneor Cheshin ,

could you please post this (https://community.ifs.com/ifs-field-service-management-fsm-employees-partners-only-103/hierarchy-select-with-mass-update-10528) convesation here? 

 

Thanks in advance,

~Juni

 

This is the answer selected as best -->

 

In this particular scenario, you have filtered the records to be mass updated based on the constraints that you have defined in the constraints and those tasks are going to be updated as per your example. But you don’t need to mention the primary key(s) in the update message since the hierarchy select is essential for the mass update to select the records. You only need to define the fields which are going to be updated in the update table section.

Again in the xml message, if you need to get xpath value, you would need to wrap the mass update message inside  perform_batch  node and before the mass update message, you could add a hierarchy select / tabular select which will only return one result. That result can be used as xpath value for the mass update message. 



<perform_batch>
<!-- your hierarchy_select / tabular_select message -->
<hierarchy_select result_name="task_dtl" return_only_requested_attrs="true">
<attrs>
<attr>task.value</attr>
<attr>test_view.value1</attr>
</attrs>
<primary_table>task</primary_table>
<from>
<table>task</table>
<table>test_view</table>
</from>
<where>
<data_constraint>
<constraint>
<left_operand>test_view.task_id</left_operand>
<operator>eq</operator>
<right_operand>@task_id</right_operand>
</constraint>
</data_constraint>
<join_constraint>
<constraint>
<left_operand>task.task_id</left_operand>
<operator>equi</operator>
<right_operand>test_view.task_id</right_operand>
</constraint>
</join_constraint>
</where>
</hierarchy_select>
<!-- your mass update message -->
<mass_update_task>
<hierarchy_select result_name = "task_dtl">
<primary_table>task</primary_table>
<attrs>
<attr>task.task_id</attr>
<attr>test_view.value1</attr>
</attrs>
<from>
<table>task</table>
<table>test_view</table>
</from>
<where>
<join_constraint>
<constraint>
<left_operand>task.task_id</left_operand>
<operator>equi</operator>
<right_operand>test_view.task_id</right_operand>
</constraint>
</join_constraint>
</where>
</hierarchy_select>
<task>
<!-- using the above hierarchy_select result in the mass update -->
<user_def10 xpath_node="//task_hierarchy_select_result[@result_name='task_dtl']/task/value" />
<user_def2 xpath_node="//task_hierarchy_select_result[@result_name='task_dtl']/task/test_view/value1" />
<update />
</task>
<transaction_size>1</transaction_size>
<synchronous>Y</synchronous>
</mass_update_task>

<!-- end of mass update -->
</perform_batch>

 

xpath would not work within mass update message itself unless you have provided a result of a select message prior to the mass update. 

Userlevel 4
Badge +11

Thanks a lot @Shneor Cheshin !

Reply