Solved

Update Part Usage XML Business Rule Error


Badge +3

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

icon

Best answer by AdrianEgley 1 May 2024, 14:59

View original

4 replies

Userlevel 1
Badge +4

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 

Badge +3

Hi Sumit,

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

 

 

Thanks,

Barry

Userlevel 5
Badge +14

@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

Badge +3

Many thanks Ady.

Thats works just how we need it to.

Regards,

Barry

Reply