jjlong - Monday, June 20, 2011 3:20 PM:
I have an ItemType named "Approval Request" which is pre-populated with several "Artifact" ItemType items we want attached to all approval requests. I have a small piece of code which I execute "OnAfterAdd" to create the related items. This code worked fine in Aras 9.2, but has stopped working in Aras 9.3.
Once I imported the package into 9.3 I started getting an error message:
Artifact with Generation '' already exists.
With indication that the unique constraint on property 'generation' is being violated when generating a new "Artifact" item.
Can anybody tell me what I am I doing wrong relative to version 9.3?
***** CODE *****
Dim myInnov As Aras.IOM.Innovator = Me.newInnovator()
Dim itemTypeSource As String = "Approval Request"
Dim itemTypeRelated As String = "Artifact"
Dim itemTypeRelationship As String = "Approval Request Artifact"
Dim i As Integer
Dim name As String
'Build a list of all the documents which are required
Dim nameArray As ArrayList = New ArrayList()
nameArray.Add("Design Document")
nameArray.Add("Architecture Drawing")
nameArray.Add("Installation Guide")
'Loop through the list of names and attach new related items to the source item
For i = 0 To nameArray.Count - 1
name = nameArray(i)
'Create a new relationship item
Dim itemRelationship As Object
itemRelationship = Me.createRelationship(itemTypeRelationship,"add")
itemRelationship.setProperty("source_id",Me.getID())
'Create the related item
Dim itemRelated As Object
itemRelated = itemRelationship.createRelatedItem(itemTypeRelated,"add")
'Assign souce item values to properties in the related item
itemRelated.setProperty("artifact_name", name)
'Update the relationship item
itemRelationship = itemRelationship.apply()
'Handle any error
If (itemRelationship.isError()) Then
Return itemRelationship
End If
Next
***** Detailed Error Message *****
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault xmlns:af="http://www.aras.com/InnovatorFault"><faultcode>SOAP-ENV:Server.PropertiesAreNotUniqueException</faultcode><faultstring>Artifact with Generation '' already exists.</faultstring><detail><af:legacy_detail>Artifact with Generation '' already exists.</af:legacy_detail><af:exception message="Artifact with Generation '' already exists." type="Aras.Server.Core.PropertiesAreNotUniqueException"><af:innerException message="Violation of UNIQUE KEY constraint." type="Aras.Server.Core.DBUniqueConstraintViolationException"><af:innerException message="Violation of UNIQUE KEY constraint 'un3583'. Cannot insert duplicate key in object 'dbo.ARTIFACT'.
The statement has been terminated." type="System.Data.SqlClient.SqlException" /></af:innerException></af:exception><af:item type="Artifact" id="2F3476911FA34144A05D536CA835DC1F" xpath="Item"><af:property name="generation" value="" /></af:item></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
Ronan - Tuesday, June 21, 2011 9:22 AM:
Hi Jeff,
What is the key of your "Artifact" itemtype? Are you certain unicity is respected regarding this key? As you said, this error message is the standard error message dumped when you don't respect unicity. Did you try to debug, to isolate the item/conditions causing the issue?
Sachin - Friday, January 13, 2012 12:33 AM:
hey
I,think you successfully import package in to Aras 9.3 Database, can you guide for import package from 9.2 to 9.3. I'm using import/export tool for upgrade/migrate. If you have any another way to upgrade then please let me know.
I already export packages from 9.2 database through import export tool , now that packages, i'm tring to import in to 9.3 database but it give lot of errors to me.
Could anyone please help me out?
Thanks in advance
Sachin G.
jjlong - Tuesday, June 21, 2011 10:19 AM:
"Artifact" is a simple ItemType with a small number of properties, mainly strings set by lists or filter lists. We did not define a unique key. The error is occurring with 'generation' which is an Aras property. generation is the only property with unique set to true. We display generation, but otherwise do not touch it. In debugging I tried setting generation, and got the same error except it showed my integer value instead of a null string which I usually get.
I've attached a screen print of the ItemType definition and the ItemType definition report. You should see I am not doing anything too exotic.
Anonymous - Wednesday, January 18, 2012 3:20 PM:
hi sachin,
i think that is not the tool for upgrads. it seems there is mor to upgrades than just changing binarys like differeinces in data structures.
i think from 9.2 - 9.3 when i was in class there was talk of other changes like bool to str; merging and splitting tables and such. i seems it would be quite hard to know all of these places and you would risk corrupting your data and other such things to try to use this tools.
if you are not in production it seems to maybe stand up the new version instead of try to upgrade by yourself is the best option, otherwise maybe call aras.
eva
jjlong - Tuesday, June 21, 2011 10:24 AM:
ps. In the code snippet I changed the name of the property I was setting to be "artifact_name" to make the example clear. The real property name is "sdp_artifact". It really has nothing to do with the error, and I only mention it because you may see the inconsistency between the code snippet and the ItemType definition.
Sachin - Wednesday, January 18, 2012 11:54 PM:
Hey
Thanks for your reply
Now i decide to move records from 9.2 to 9.3 , like table vies , without using any tool,
is it safe...., i'm also skipping existing records in new database.
Sachin
Ronan - Tuesday, June 21, 2011 10:38 AM:
Hi,
This item definition looks strange: here you are saying that, at all times in the ARTIFACT table, generation must be unique. So if you create an item (getting generation 1) and immediately create a second one, the second one won't be created because generation 1 already exists (with item1). Usually a tuple of attributes is unique (e.g. {name, generation} or {item_number, generation}, but not generation alone), have a look at the definition of Document for example. Here you should either remove the Unique constraint to generation, or add Unique to a second property, like sdp_pts_number.
Are you sure this worked in 9.2?
?
Ronan Jouchet - PLM Consultant, Processia Solutions
jjlong - Tuesday, June 21, 2011 11:10 AM:
Yes, ARTIFACT worked in 9.2, and was transferred to 9.3 through a package export/import.
I did not set the Unique constraint for ARTIFACT, it was pre-set by Aras when I performed a "New ItemType" when I first defined the ARTIFACT ItemType in 9.2. I just ran a simple test of creating an ItemType in 9.2 and 9.3 containing only the default properties. When I compare the default properties I see than in 9.2 Unique is set to true for generation, but in 9.3 Unique is set to false. This appears to be the difference I'm looking for.
I removed the Unique constraint from generation in ARTIFACT and now the code works! Thank you.
I hesitated to remove the Unique constraint previously as I assumed Aras required it to be set. Since it is not set by default in 9.3 I think I am ok in removing the setting. I need to do some more thorough testing, but it appears this solves the problem.
kentonv - Thursday, June 30, 2011 4:51 PM:
Perhaps generation is no longer populated in 9.3 for non-version controlled items.
Either way, it cannot be the only unique item in the item type. You may be able to use not unique values, or use your keyed-order columns.