This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SUPPORT Q&A - Changing the revision

Ron - Wednesday, July 25, 2007 8:13 AM:

After uploading our parts and documents, we are now in the clean up phase of re-building the BOM's and ensuring that parts match documents and that that all parts have a supporting document. I have come across some cases where the parts revision is out of sync with the supporting document (this is why we needed a good PLM system). Question is how to correct this! Documents are at a release state and parts are at preliminary state. In this case I have a part at revision “C” and the supporting document is at Rev “D”, the part should have been at rev D, but was missed at the first stage cleaning. How can we easily change the revision of the parts to match the documents?

 

Thanks

Ron



RobMcAveney - Wednesday, July 25, 2007 11:44 AM:

Hi Ron -

The easiest way to do this is with a method.  I can provide some sample code, but first a couple questions:

  1. Is there only one Document attached to each Part?
  2. Do you want the Part to be promoted to released state as well?
Rob
 

Ron - Wednesday, July 25, 2007 1:20 PM:

Hi Rob

Yes only one doc which defines the part, generally for every custom made part their is always a supporting document to define that part and both the part and document must be at the same revision. The document is master and drives the part.

At this time I do not need the part to be promoted, this will happen thru a release process later.

 

Ron

 



RobMcAveney - Wednesday, July 25, 2007 1:53 PM:

Hi Ron -

See the sample code below.  This is a C# server method that finds all the Part/Document relationships with mismatched revisions and modifies the Part rev to match the document.  To use it, just create a new method item, cut/paste the below code, save and use the Run Server Method action (from the Actions menu on the Method form).  After the method has run, you should get a window that shows a log of the results.  I would strongly suggest backing up your database before running the method.  You might also want to do a dry run by commenting out the "partItem = partItem.apply();" line -- this will tell you which items will have their revs changed without actually doing it.

Innovator inn = this.newInnovator();
string resultString = " ";
string targetState = "Released";

// Build a where clause that finds only current Parts with an attached document of a different rev
string whereClause = "(select is_current from [PART] where id=[PART_DOCUMENT].source_id) = '1' AND ";
whereClause += "(select major_rev from [PART] where id=[PART_DOCUMENT].source_id) != ";
whereClause += "(select major_rev from [DOCUMENT] where id=[PART_DOCUMENT].related_id)";

// Query for 'Part Document' relationships that match the where clause
Item partDoc = this.newItem("Part Document","get");
partDoc.setAttribute("select","source_id(item_number,major_rev),related_id(item_number,major_rev)");
partDoc.setAttribute("where",whereClause);
partDoc = partDoc.apply();
if (partDoc.isError()) return inn.newError("Error finding 'Part Document' relationships: "+partDoc.getErrorDetail());

// Loop through the 'Part Document' relationships and attempt to set the revision
for (int i=0; i<partDoc.getItemCount(); i++) {
 string docRev = partDoc.getItemByIndex(i).getRelatedItem().getProperty("major_rev");
 string partId = partDoc.getItemByIndex(i).getProperty("source_id");
 string partNumber = partDoc.getItemByIndex(i).getPropertyItem("source_id").getProperty("item_number");
 string partRev = partDoc.getItemByIndex(i).getPropertyItem("source_id").getProperty("major_rev");
 // Edit the Part revision
 Item partItem = this.newItem("Part","edit");
 partItem.setID(partId);
 partItem.setAttribute("version","0");
 partItem.setProperty("major_rev",docRev);
 partItem = partItem.apply();
 // Log the result
 if (partItem.isError()){
  resultString+="Part item_number='"+partNumber+"' id='"+partId+"': ERROR setting revision: "+partItem.getErrorDetail()+" ";
 } else {
  resultString+="Part item_number='"+partNumber+"' id='"+partId+"': Revision changed from '"+partRev+"' to '"+docRev+"' ";
 }
}
// Return a log of the results
return inn.newResult(resultString);

Let me know how it works out.

Good luck -

Rob 



Ron - Thursday, July 26, 2007 8:25 AM:

Rob, thanks for the response, it worked but like life nothing is simple. I ran the method in our Beta enviroment with the apply results turned off (good suggestion), as it turns out Yes we do have cases where the supporting doc does not match the revision of the part. Purchased items which have a component specification or a material specification, which there are many. I was only thinking of drawings for custom made items, this method did provide a list which I am able to find all the drawings which do not have matching revisions. With the results, I will now have to get someone to review each item and find out why and which revision is correct and then based on the findings most likely just go directly into the database and change the revision of the parts/documents.

 

Thanks for your help.

 

Ron