Skip to main content

I am attempting to update all part usage lines on a Task when task.user_def4 is set to a particular value.

I have setup a Custom Process XML business rule with TASK as the Primary Table and this is firing when task.user4 is set. The Custom Process is shown below.

I want to update part_usage.part_line_code on all part usage lines on the task. The Business Rule is shown below.

The error I get when my BR fires is  “Attempt to update a record without providing all Primary Key information”.

My XML is as follows.

 

<update_part_usage>
<part_usage>
<part_usage>@task_id</part_usage>
<part_line_code>MIS</part_line_code>
<update/>
</part_usage>
</update_part_usage>

 

Any guidance on where i have gone wrong would be appreciated.

Thanks,

Barry

Hi @MWAMAITTEAM ,

 

     Can you try this code?

<update_part_usage>
  <part_usage>
    <pu_id />
<part_usage>@task_id</part_usage>
<part_line_code>MIS</part_line_code>
    <update />
  </part_usage>
</update_part_usage>

 

Thanks

Sumit 


Hi Sumit,

I have updated the XML as per your code but still seeing the error below when it fires.

 

 

Thanks,

Barry


@MWAMAITTEAM 

 

The primary key will relate to not knowing which PU_ID to update. The other option would be to use a mass_update XML.

 

<mass_update_part_usage>
  <hierarchy_select>
    <primary_table>part_usage</primary_table>
    <attrs>
      <attr>part_usage.pu_id</attr>
    </attrs>
    <from>
      <table>part_usage</table>
    </from>
    <where>
      <data_constraint>
        <constraint>
          <left_operand>part_usage.task_id</left_operand>
          <operator>eq</operator>
          <right_operand>@task_id</right_operand>
        </constraint>
      </data_constraint>
    </where>
  </hierarchy_select>
  <part_usage>
    <part_line_code>MIS</part_line_code>
    <update />
  </part_usage>
  <transaction_size>100</transaction_size>
  <synchronous>Y</synchronous>
</mass_update_part_usage>

This should locate all Part Usages and set the Line Code based on that task id.

 

Ady


Many thanks Ady.

Thats works just how we need it to.

Regards,

Barry


Reply