This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - AML for Part Goal

robos - Saturday, September 20, 2014 5:51 PM:

Hi,

I try to insert cost goal with the following AML :

<AML>

  <Item type="Part" action="merge" where="item_number='115150'">

    <item_number>115150</item_number>

    <name>TEST</name>

    <Relationships>

      <Item type="Part Goal" action="add">

        <related_id>

          <Item type="Part Goal" action="add">

            <goal>Cost</goal>

            <actual_value>2018.69</actual_value>

          </Item>

        </related_id>

      </Item>

    </Relationships>

  </Item>

</AML>

 

And I am getting following fault :

<![CDATA[Cannot insert the value NULL into column 'GOAL', table 'InnovatorSolutionst.innovator.PART_GOAL';....

Why is that ? GOAL field in AML is properly populated ?

And next question, how would I construct AML if I would like to use on Part Goal item merge instead of add ? I have to update actual costs regulary because they do change over time. 

Thanks for your help !

Bostjan

 

 



DavidSpackman - Sunday, September 21, 2014 10:36 PM:

Hi Bostjan, 

 

Your query was not quite correct.

This should work for your initial query:

<AML>
  <Item type="Part" action="merge" where="item_number='115150'">
    <item_number>115150</item_number>
    <name>TEST</name>
    <Relationships>
      <Item type="Part Goal" action="add">
        <goal>Cost</goal>
        <actual_value>2018.69</actual_value>
      </Item>
    </Relationships>
  </Item>
</AML>

 

To answer your second question, all you need to do is find a property that is relevant for the item you want to update, in this case we know goal will also be cost.

Note, I have set version to 0 for the Part item, this will prevent a new generation being created each time you update the cost. Setting this will depend on your own requirements.

<AML> 
  <Item type="Part" action="merge" where="[Part].item_number='115150'" version="0"> 
    <item_number>115150</item_number> 
    <name>TEST</name> 
    <Relationships> 
      <Item type="Part Goal" action="merge" where="[Part_Goal].goal='Cost'"> 
        <goal>Cost</goal> 
        <actual_value>2058</actual_value> 
      </Item> 
    </Relationships> 
  </Item> 
</AML>

 

Dave



robos - Monday, September 22, 2014 2:29 AM:

Hi David,

Thank you for quick and very valuable answer !

Now it works as expected. 

 

Best regards,

Bostjan