Skip to main content
Question

Hierarchy_select not working as intended

  • June 15, 2020
  • 1 reply
  • 114 views

Forum|alt.badge.img+5
  • Do Gooder (Customer)
  • 5 replies

Quite new to this, but encountered an issue left over by our developers on a business rule:

The business rule should update all related task_contacts with the information on request_contact when the request_contact is updated.

What we see is that only the first result from the hierarchy_select_result is being updated.

How can this business rule be improved to actually update all task_contacts on all related tasks?

 

BR:

<perform_batch>
 <hierarchy_select result_name="NonCompletedTask">
  <attrs>
   <attr>task.task_id</attr>
  </attrs>
  <primary_table>task</primary_table>
  <from>
   <table>task</table>
  </from>
  <where>
   <data_constraint>
    <constraint>
     <left_operand>task.request_id</left_operand>
     <operator>eq</operator>
     <right_operand>@request_id</right_operand>
    </constraint>
    <constraint>
     <left_operand>task.task_status</left_operand>
     <operator>ne</operator>
     <right_operand>TECH COMPLETE</right_operand>
    </constraint>
    <constraint>
     <left_operand>task.task_status</left_operand>
     <operator>ne</operator>
     <right_operand>COMPLETED</right_operand>
    </constraint>
    <constraint>
     <left_operand>task.task_status</left_operand>
     <operator>ne</operator>
     <right_operand>CLOSED</right_operand>
    </constraint>
   </data_constraint>
  </where>
 </hierarchy_select>
 <hierarchy_select result_name="TaskContact">
  <attrs>
   <attr>task_contact.task_id</attr>
   <attr>task_contact.user_def3</attr>
   <attr>task_contact.sequence</attr>
  </attrs>
  <primary_table>task_contact</primary_table>
  <from>
   <table>task_contact</table>
  </from>
  <where>
   <data_constraint>
    <constraint>
     <left_operand>task_contact.task_id</left_operand>
     <operator>eq</operator>
     <right_operand>
      <task_id xpath_node="//task_hierarchy_select_result[@result_name='NonCompletedTask']/task/task_id"/>
     </right_operand>
    </constraint>
    <constraint>
     <left_operand>task_contact.user_def3</left_operand>
     <operator>eq</operator>
     <right_operand>@user_def3</right_operand>
    </constraint>
   </data_constraint>
  </where>
 </hierarchy_select>
 <update_task_contact>
  <task_contact>
   <task_id xpath_node="//task_hierarchy_select_result[@result_name='NonCompletedTask']/task/task_id"/>
   <email_address>@email_address</email_address>
   <first_name>@first_name</first_name>
   <last_name>@last_name</last_name>
   <home_phone>@home_phone</home_phone>
   <mobile_phone>@mobile_phone</mobile_phone>
   <phone>@phone</phone>
   <user_def1>@user_def1</user_def1>
   <user_def3>@user_def3</user_def3>
   <user_def9>@user_def9</user_def9>
   <user_def10>@user_def10</user_def10>
   <user_def11>@user_def11</user_def11>
   <user_def12>@user_def12</user_def12>
   <user_def13>@user_def13</user_def13>
   <user_def14>@user_def14</user_def14>
   <user_def15>@user_def15</user_def15>
   <user_def16>@user_def16</user_def16>
   <user_def17>@user_def17</user_def17>
   <user_def18>@user_def18</user_def18>
   <user_def19>@user_def19</user_def19>
   <user_def20>@user_def20</user_def20>
   <user_def21>@user_def21</user_def21>
   <user_def22>@user_def22</user_def22>
   <user_def23>@user_def23</user_def23>
   <user_def24>@user_def24</user_def24>
   <user_def25>@user_def25</user_def25>
   <sequence xpath_node="//task_contact_hierarchy_select_result[@result_name='TaskContact']/task_contact/sequence"/>
   <update/>
  </task_contact>
 </update_task_contact>
</perform_batch>

 

1 reply

Forum|alt.badge.img+4
  • Sidekick (Partner)
  • 15 replies
  • August 24, 2021

Use mass_update instead of perform_batch:

 

<mass_update_task_person>
	<hierarchy_select>
		<attrs>
			<attr>task_contact.task_id</attr>
		</attrs>
		<from>
			<table>task_contact</table>
			<table>task</table>
		</from>
		<where>
			<join_constraint>
				<constraint>
					<right_operand>task.task_id</right_operand>
					<operator>equi</operator>
					<left_operand>task_contact.task_id</left_operand>
				</constraint>
			</join_constraint>
			<data_constraint>
				<constraint>
					<left_operand>task.request_id</left_operand>
					<operator>eq</operator>
					<right_operand>@request_id</right_operand>
				</constraint>
				<constraint>
					<left_operand>task.task_status</left_operand>
					<operator>ne</operator>
					<right_operand>TECH COMPLETE</right_operand>
				</constraint>
				<constraint>
					<left_operand>task.task_status</left_operand>
					<operator>ne</operator>
					<right_operand>COMPLETED</right_operand>
				</constraint>
				<constraint>
					<left_operand>task.task_status</left_operand>
					<operator>ne</operator>
					<right_operand>CLOSED</right_operand>
				</constraint>
				<constraint>
					<left_operand>task_contact.user_def3</left_operand>
					<operator>eq</operator>
					<right_operand>@user_def3</right_operand>
				</constraint>
			</data_constraint>
		</where>
	</hierarchy_select>
	<task_contact>
		<email_address>@email_address</email_address>
		<first_name>@first_name</first_name>
		<last_name>@last_name</last_name>
		<home_phone>@home_phone</home_phone>
		<mobile_phone>@mobile_phone</mobile_phone>
		<phone>@phone</phone>
		<user_def1>@user_def1</user_def1>
		<user_def3>@user_def3</user_def3>
		<user_def9>@user_def9</user_def9>
		<user_def10>@user_def10</user_def10>
		<user_def11>@user_def11</user_def11>
		<user_def12>@user_def12</user_def12>
		<user_def13>@user_def13</user_def13>
		<user_def14>@user_def14</user_def14>
		<user_def15>@user_def15</user_def15>
		<user_def16>@user_def16</user_def16>
		<user_def17>@user_def17</user_def17>
		<user_def18>@user_def18</user_def18>
		<user_def19>@user_def19</user_def19>
		<user_def20>@user_def20</user_def20>
		<user_def21>@user_def21</user_def21>
		<user_def22>@user_def22</user_def22>
		<user_def23>@user_def23</user_def23>
		<user_def24>@user_def24</user_def24>
		<user_def25>@user_def25</user_def25>
		<update/>
	</task_contact>
</mass_update_task_person>

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings