Tuesday 1 March 2016

Aras Item update using AML

Step 1 lock: It will lock all revs of documents
<Item type="Document" action="lock" where="[Document].item_number='ABC'"></Item>

Step 2 Find user locked_by_id:
<Item action="get" type="Document"" where="[Document"].item_number='ABC'" select="locked_by_id">
</Item>

Now- you will get the result as below:

<locked_by_id keyed_name="test User" type="User">USERID456</locked_by_id>

Note down this Id, you will use in step 4

Step 3 update document with different owned_by_id:

<Item type="Document" action="update" version="0" where="[Document].item_number='ABC' and [Document].generation='1'"><owned_by_id>GUID123</owned_by_id></Item>

Note: Use: version="0", so that it will not generate new rev.

Step 4 unlock the item: It will unlock all revs
<Item type="document" action="unlock" where="[document].locked_by_id='USERID456'"></Item>