MMarcial - Monday, August 20, 2007 1:27 PM:
On the ECN I entered:
Affected Part: 000123 (Type field automatically turns to part icon)
Action: Delete
Interchangable: (left blank)
Superseding Number: (left blank)
Superseding Rev: (left blank)
In Build: Scap
in Service: Scrap
The part stays in the Design listing in the Released state.
Why is the ECN process is not deleting a part?
RobMcAveney - Tuesday, August 21, 2007 11:11 AM:
This is expected behavior. An ECN tracks when parts are added/changed/deleted from configurations, not from the database. Removing it from the database would effectively remove any trace of that part ever existing, which is not good practice. More likely, you want to change the state of the part to something like Obsolete or Superseded or Retired. In the out-of-the-box solution, this would be a manual operation based on the desired future usage of the part. Removing a part from a configuration does not always mean obsoleting it, as it may be acceptable to use it later in another context. If you have a specific business rule that decides what happens to part records when they are removed from configurations, that rule can be added to the ECN logic.
MMarcial - Wednesday, August 22, 2007 4:34 PM:
Rob,
I do need to remove parts and documents with attached files from the database such that all traces of that part never existed. My company is selling off a part of the product line and I would like to give the buyer a copy of Aras Innovator with just parts needed for their product line.
Any Advice?
I suspect thiis code from the help file will DESTROY the part.
DeleteItem
Arguments: None
Returns: Boolean Status
Description: This method will delete all versions of the Item. If the Item is not versionable the Item is still deleted.
Example:
Dim myInnovator: Set myInnovator = new Innovator
Dim qry: Set qry = new QryItem
qry.setItemType "Part"
qry.setCriteria "part_number", "123", "eq"
Dim items: Set items = qry.Execute
If items is Nothing Then
Dim lastFault: Set lastFault = qry.GetLastFault
SetResult outDom, lastFault.GetFaultDetails
Else
Dim keys: keys = items.Keys
Dim thisItem: Set thisItem = items.item(keys(0))
If Not thisItem.DeleteItem Then
Dim lastFault: Set lastFault = qry.GetLastFault
SetResult outDom, lastFault.GetFaultDetails
Else
SetResult outDom, "Item Deleted."
End If
End If
Can you post a this code in VB.NET syntax?
If the code deletes a Document, will it remove the file from the vault?
MM
RobMcAveney - Wednesday, August 22, 2007 11:17 PM:
Hi MM -
In the situation you describe, I would suggest removing access to the items instead of deleting them. Deleting means you have to first remove all references to all versions of the item, which is possible but can be a hassle. I can put together an Action to help with that, but it may be a few days before I can get to it. Removing access is much simpler:
- Create a new Permission with no Get access for anyone (or maybe only Administrators)
- Edit the Part/Document LifeCycle to create a new state named something like like "Removed"
- Set the state permission to reference the Permission you added
- Create a transition Released to Removed and assign it to Administrators
- Select the Parts and Documents and promote them manually to Removed
Hope that helps -
Rob
SamsAn - Friday, August 24, 2007 12:18 PM:
Hi.
Use the steps below to have the required behavior.
1. Create two new server-side Methods (type=VB for example) with the following code:
a. ECN_onBeforeDelete
Dim tmpInn As Innovator = Me.newInnovator()
Dim q As Item = tmpInn.newItem("tmp", "tmp")
Dim x As String = String.Format("<Item type=""Part"" action=""get"" select=""id"" where=""[Part].id IN (SELECT affected_id FROM [Affected_Item] WHERE id IN (SELECT related_id FROM [ECN_Affected_Item] WHERE source_id='{0}'))""/>", Me.getAttribute("id"))
Dim itm As Item
Dim i As Integer
Dim uniqueKeyInSession As String = "your_custom_unique_key_for_part_ids2delete" + Me.GetAttribute("id")
q.loadAML(x)
q = q.apply()
Dim partIds2Delete As New ArrayList
For i=0 To q.getItemCount()-1
itm = q.getItemByIndex(i)
partIds2Delete.Add(itm.getAttribute("id"))
Next i
CCO.Session(uniqueKeyInSession) = partIds2Delete
b. ECN_onAfterDelete
Dim tmpInn As Innovator = Me.newInnovator()
Dim q As Item = tmpInn.newItem("tmp", "tmp")
Dim r As Item
Dim x As String = "<Item type=""Part"" action=""delete""/>"
Dim id As String
Dim i As Integer
Dim uniqueKeyInSession As String = "your_custom_unique_key_for_part_ids2delete" + Me.GetAttribute("id")
q.loadAML(x)
Dim partIds2Delete As ArrayList = CType(CCO.Session(uniqueKeyInSession), ArrayList)
For i=0 To partIds2Delete.Count()-1
id = partIds2Delete.Item(i)
q.setAttribute("id", id)
r = q.apply()
If r.IsError() Then
CCO.Session.Remove(uniqueKeyInSession)
Return r 'if the Part item cannot be deleted then ECN item delete will fail with the corresponding warning.
End If
Next i
CCO.Session.Remove(uniqueKeyInSession)
Return tmpInn.newResult("No Problem. Hope It Helps :)")
2. Edit ECN ItemType, go to Server Events tab and create two records (OnBeforeDelete, OnAfterDelete) with the corresponding methods assigned.
3. The behavior is configured. If you want to get the code explanations, please let me know.
Hope it helps.
MMarcial - Monday, August 27, 2007 2:59 PM:
Rob,
Your "No Get" method partially works. It gets removed from the Design list but is still accessible if the part is on the BOM of another part. In addition, the part/document can still be queried using T-SQL exposing vendor part numbers and descriptions amoung other fields. Also, the Vault could be browsed with File Explorer to uncover design documents.
In addition the part can be brought bad to life by updating, via T-SQL, the [state], [current_state] and [permission_id] fields of the Parts table.
MM
MMarcial - Monday, August 27, 2007 2:05 PM:
Hi SamsAn,
Please provide code explanations.
The technique provided did not execute as desired. I am confused about
- source_id='{0}' - why 0 (zero)
- "your_custom_unique_key_for_part_ids2delete" - It seems to me that Me.GetAttribute("id") would be unique if I can assure I am the only user logged into Innovator.
MM
SamsAn - Tuesday, August 28, 2007 3:46 AM:
Hi.
1. source_id='{0}' - why 0 (zero)
Explanation: please note, that it is used inside String.Format method (for the best performance). Thus {0} is replaced by Me.getAttribute("id") and we get the desired query.
2. "your_custom_unique_key_for_part_ids2delete" - It seems to me that Me.GetAttribute("id") would be unique if I can assure I am the only user logged into Innovator.Explanation: i put the prefix (and use this trick in like situations) because of two reasons. First, it cannot be messed with Me.GetAttribute("id") key (let assume the standard solution developer already uses this key in the session, do we have to handle this case?). Second, the key prefix is convenient during debugging (it is easy to find this key in Session object using a debugger).
Hope it helps.