jh1234 - Monday, September 21, 2015 11:22 AM:
zahar - Tuesday, September 22, 2015 8:21 AM:
Hi,
You need to split your code to 2 steps:
1) Get the ID for the Simple ECO
2) Use the second request to get the workflow associated with this Eco
Something like this (please fix the syntax to align with VB.NET)
1)
jh1234 - Tuesday, September 22, 2015 8:39 AM:
Thanks for your response - do you know if there is a way I can get to the workflow process activity using vb.net rather than AML (more than anything just for my knowledge and to keep my code tidy!)
Also, I know the code snippet I posted finds the active workflow process activity, but do you know what I would search for to find the date a given workflow process was signed off (we have an activity called ECR Review, for example)? I have not done much with these items before so its all a bit unfamiliar to me.
Thanks again for your help!
zahar - Tuesday, September 22, 2015 9:01 AM:
For me, using AML and not code, is a more visual way to understand the DB structure. Don't forget that vb.net code actually just build the AML and sent to server AML.
Another point that you need to consider is that it much easy to debug AML, cause you can copy the AML to AML Studio and run it against the DB and see what you get from the server without running your code.
But here is the code in VB.NET that equals to one i sen't you before
Dim qryWF As Item = Me.getInnovator().newItem("Workflow", "get")
qryWF.setProperty("source_id", ecoData.getID())
Dim relatedWorkflowProcess As Item = qryWF.createRelatedItem("Workflow Process")
Dim WorkflowProcessActivityRel As Item = relatedWorkflowProcess.createdRelationship("Workflow Process Activity", "get")
Dim ActivirtItem As Item = WorkflowProcessActivityRel.createRelatedItem("Workflow Process")
ActivirtItem.setProperty("state", "Active")
Dim result As Item = qryWF.apply()
zahar - Tuesday, September 22, 2015 9:11 AM:
If i understood what you want is to get closed_date of specific activity that linked to WF of your ECO ?
if so you just need to update the AML (or code) instead <state>Active</state> to:
<state>Close</state>
<cloned_as condition="is null" />
<name>{Name of the activity}</name>
And then after you receive a response from the server do something like this:
Dim activity as Item = result.getItemsByXPath("//Item[@type='Activity']");
If activity.getItemCount() > 0 then
activity = activity.getItemByIndex(0)
string close_date = activity.getProperty("closed_date", "");
end if
jh1234 - Tuesday, September 22, 2015 1:58 PM:
Great - some of this makes sense to me... but not all!
Firstly, I will look into AML studio, but for now I'm stuck working with VB.net - but it looks like a useful tool, so thanks for brining it to my attention.
Second, yes, you have understood my requirement correctly ( I am after the date) - when I put your code together, I get this:
Dim qryWF As Item = MyInnovator.newItem("Workflow", "get")
qryWF.setProperty("source_id", ecoData.getID())
Dim relatedWorkflowProcess As Item = qryWF.createRelatedItem("Workflow Process") //this line gives an error - too few arguments
Dim WorkflowProcessActivityRel As Item = relatedWorkflowProcess.createRelationship("Workflow Process Activity", "get")
Dim ActivirtItem As Item = WorkflowProcessActivityRel.createRelatedItem("Workflow Process") //this line gives an error - too few arguments
ActivirtItem.setProperty("state", "Close")
ActivirtItem.setProperty("name", "Review ECR")
Dim result As Item = qryWF.apply()
Dim activity As Item = result.getItemsByXPath("//Item[@type='Activity']")
If activity.getItemCount() > 0 Then
activity = activity.getItemByIndex(0)
Dim close_date As String = activity.getProperty("closed_date")
Debug.WriteLine("close date = " & close_date)
End If
Which gives me 2 questions:
- Why am I using the "createRelatedItem" and "createRelationship" commands? Why do I need to create anything - am I not just reading from the database?
- On the lines indicated; as the action is not specified I can't compile the code. I attempted to "fix" the above, and changed it to this:
Dim qryWF As Item = MyInnovator.newItem("Workflow", "get")
qryWF.setProperty("source_id", ecoData.getID())
Dim relatedWorkflowProcess As Item = qryWF.createRelatedItem("Workflow Process", "get")
Dim WorkflowProcessActivityRel As Item = relatedWorkflowProcess.createRelationship("Workflow Process Activity", "get")
Dim ActivirtItem As Item = WorkflowProcessActivityRel.createRelatedItem("Workflow Process", "get")
ActivirtItem.setProperty("state", "Close")
ActivirtItem.setProperty("name", "Review ECR")
Dim result As Item = qryWF.apply()
Dim activity As Item = result.getItemsByXPath("//Item[@type='Activity']")
If activity.getItemCount() > 0 Then
activity = activity.getItemByIndex(0)
Dim close_date As String = activity.getProperty("closed_date")
Debug.WriteLine("close date = " & close_date)
End If
But it doesn't return a date; and I'm not sure how I can tell if I'm even close! I know it finds the ECO I'm using as a starting point OK; but after that I'm a bit lost.
Thanks again for all your help with this, I really appreciate it!
zahar - Tuesday, September 22, 2015 2:40 PM:
Your question indicates that you miss the point that I'm trying to explain:
from line:
Dim qryWF As Item = MyInnovator.newItem("Workflow", "get")
till the line
ActivirtItem.setProperty("name", "Review ECR")
jh1234 - Tuesday, September 22, 2015 4:36 PM:
Thanks again for your help - I understand that the xml is being built up until the point it is sent to the server with the qryWF.apply() command. And therefore (if I have understood you correctly!) the "createRelatedItem" and "createRelationship" commands are creating lines in my query rather than items in the database - thank you for clarifying - it helps me a lot!
Also, the Debug.WriteLine(result.dom.OuterXml) line is very useful; and so using the code from my last post it returns returned the following:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="schemas.xmlsoap.org/.../"><SOAP-ENV:Body><SOAP-ENV:Fault xmlns:af="www.aras.com/.../faultcode><faultstring><![CDATA[No items of type Workflow found.]]></faultstring><detail><af:legacy_detail><![CDATA[No items of type Workflow found.]]></af:legacy_detail><af:legacy_faultstring><![CDATA[No items of type 'Workflow' found using the criteria:
<Item isNew="1" isTemp="1" type="Workflow" action="get">
<source_id>4FEA947FF6604A6BA007D4971A01E4C4</source_id>
<related_id>
<Item isNew="1" isTemp="1" type="Workflow Process" action="get">
<Relationships>
<Item isNew="1" isTemp="1" type="Workflow Process Activity" action="get">
<related_id>
<Item isNew="1" isTemp="1" type="Workflow Process" action="get">
<state>Close</state>
<name>Review ECR</name>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
</related_id>
</Item>
]]></af:legacy_faultstring></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
This made me think that a few of the items in my query were in the wrong order - so I changed it to:
Dim qryWF As Item = MyInnovator.newItem("Workflow", "get")
qryWF.setProperty("source_id", ecoData.getID())
Dim relatedWorkflowProcess As Item = qryWF.createRelatedItem("Workflow Process", "get")
Dim WorkflowProcessActivityRel As Item = relatedWorkflowProcess.createRelationship("Workflow Process Activity", "get")
Dim ActivirtItem As Item = WorkflowProcessActivityRel.createRelatedItem("Activity", "get")
ActivirtItem.setProperty("state", "Close")
ActivirtItem.setProperty("name", "Review ECR")
Dim result As Item = qryWF.apply()
Debug.WriteLine(result.dom.OuterXml)
Dim activity As Item = result.getItemsByXPath("//Item[@type='Activity']")
If activity.getItemCount() > 0 Then
activity = activity.getItemByIndex(0)
Dim close_date As String = activity.getProperty("closed_date")
Debug.WriteLine("close date = " & close_date)
End If
The resulting xml is a bit too long to post - but it returns the closed date which is brilliant, and I understand how I got there too. So (as long as you can't see anything wrong with the above) it seems to be working!
One last question though just to complete my understanding - how is getItemsByXPath working? its not something I have used before. if I change the 'Activity' to 'Workflow Process' for example, could I interrogate the properties of the workflow process in the same way? Is using getItemsByXPath the most efficient way of doing this?
Thanks again!
zahar - Wednesday, September 23, 2015 1:32 PM:
Good, you have understood me correctly.
Happy that my answers helped you to figure what was the problem.
About the getItemsByXPath...
As you noticed, in Aras, the query and the answers - are XMLs. So when you received the answer from the server, it actually XML. So what Aras IOM is doing is converting this XML to some .NET object that make parsing of this XML much easier.
XPath is the way you can select some data from XML. Is the same like you can use SQL to select data from Database.
Google XPATH and you can find tons of manual.
All you need to know about getItemsByXPath - is like "createRelatedItem" this function is running on xml and not accessing db. It gets XMLNodes from result XML and convert it to a list of Aras Items
jh1234 - Wednesday, September 23, 2015 1:42 PM:
Thank you Zahar, once again really helpful explanation!