AML problem using action='update' (in order to modify an item without changing generation)

Hi 

I am facing a problem with an AML expression.

<AML>
  <Item action='update' type='myItem' where="[myItem]._title='myItemName' and [myItem].generation='1' ">
  <myItemProperty>
    <Item type="myItemProperty" action="get" select="id">
      <keyed_name>myItemPropertyName</keyed_name>
    </Item>
  </myItemProperty>
</AML>

That AML works with edit but it changes the generation...

I get that error whatever my item is locked or unlocked...

<SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../">
  <SOAP-ENV:Body>
    <SOAP-ENV:Fault xmlns:af="">www.aras.com/InnovatorFault">
      <faultcode>SOAP-ENV:Server.ItemIsNotLockedException</faultcode>
      <faultstring><![CDATA[Aras.Server.Core.ItemIsNotLockedException]]></faultstring>
      <detail>
        <af:legacy_detail><![CDATA[Aras.Server.Core.ItemIsNotLockedException]]></af:legacy_detail>
        <af:exception message="Aras.Server.Core.ItemIsNotLockedException" type="Aras.Server.Core.ItemIsNotLockedException" />
        <af:item type="myItem" id="5CC09554029A4E76AD0601C9F8C2AC33" />
      </detail>
    </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Any idea ?

Best regards,

Hadrien

Parents
  • Hi Hadrien

    Edit and Update operation will do the same and change the generation. However below are the differences

    Differences b/w Edit and Update

    Edit - Will lock the item, Update the changes, Unlock the item

    Update - Check whether the item is locked or not, Update the changes if it is locked, Leave the item remain locked.

    So, when you apply Upate action, System will check whether item is already locked or not and throw Item not locked exception.

    Usage

    Edit - Can be used in executing the query in Nash / Innovator Admin tool.

    Update - Can be used in Server / Client side method where item is locked already and need to keep that item locked by same user.

    Solution for this Question

    Use Version = '0' in your AML query to prevent changing the generation

    <AML>
      <Item action='edit' type='myItem' where="[myItem]._title='myItemName' and [myItem].generation='1'" version='0'>
      <myItemProperty>
        <Item type="myItemProperty" action="get" select="id">
          <keyed_name>myItemPropertyName</keyed_name>
        </Item>
      </myItemProperty>
    </AML>

    If you know the exact ID of the generation you want to update, then this query can be simplified 

    <AML>
      <Item action='edit' type='myItem' id='ID OF EXACT GENERATION' version='0'>
      <myItemProperty>
        <Item type="myItemProperty" action="get" select="id">
          <keyed_name>myItemPropertyName</keyed_name>
        </Item>
      </myItemProperty>
    </AML>

    Note: If you really want to use Update action in you query then below query will work

    <AML>
    <Item action='lock' id='ID OF EXACT GENERATION YOU WANT TO LOCK AND UPDATE' type='myItem'>
    </Item>
    <Item action='update' type='myItem' where="[myItem]._title='myItemName' and [myItem].generation='1'" version='0'>
      <myItemProperty>
        <Item type="myItemProperty" action="get" select="id">
          <keyed_name>myItemPropertyName</keyed_name>
        </Item>
      </myItemProperty>
      </Item>
    </AML>

    Thank You

    Gopikrishnan R

  • Thanks for you replies I will test it :)

    Best regards,

    Hadrien

Reply Children
No Data