Forum Discussion

Former_Member's avatar
Former_Member
Accelerator III
8 years ago

HOW TO DEFINE SEQUENCE NUMBER TO A DOCUMENT SUB TYPE?

I have a Design Document as sub item type of Document and would like to assign a different sequence number to the “Document Number” attribute and how to achieve this?

8 Replies

  • One way might be: First set the "Document Number" Property to string, then you can use the onBeforeAdd event to call a method. The Method should check for (this.classification == "SubType") and  use getNextSequence("") to get the next number from your sequences. Something like: Innovator inn = this.getInnovator(); if (this.getProperty("classification","") == "SubClass") { this.setProperty("Document Number",inn.getNextSequence("mySequence_1") ) } else { this.setProperty("Document Number",inn.getNextSequence("mySequence_2") ) } return this;
  • Thank you for the reply. Is it not possible change the property itself for different types? Like in the configuration page. I don't like writing code against each type. I have created sequences for different types and want to edit the property "item_number" as sequence and select the sequence against each sub type. Is that possible?
  • getting this error: SOAP-ENV:Envelope> -<SOAP-ENV:Body> -<SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>'./Document Number' has an invalid token.</faultstring> -<detail> <af:legacy_detail>'./Document Number' has an invalid token.</af:legacy_detail> <af:exception message =" './Document Number' has an invalid token. " type ="System.Xml.XPath.XPathException " /> </detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>   code is : Innovator inn = this.getInnovator(); if (this.getProperty("classification","") == "Design Document") { this.setProperty("Document Number",inn.getNextSequence("Design Document")); } else if (this.getProperty("classification","") == "Engineering Document") { this.setProperty("Document Number",inn.getNextSequence("Engineering Document")); } else if (this.getProperty("classification","") == "Specification Document") { this.setProperty("Document Number",inn.getNextSequence("Specification Document")); } return this;  
  • Q1) Have you created the sequences Design Document, Engineering Document, Specification Document? Q2) Does your field "Document Number" actually refer to the property "item_number"? If so, try changing "Document Number" to "item_number" If you do not wish to use code, you may be able to do something with xProperties, but I have not used these yet. Many thanks Martin.
  • Innovator inn = this.getInnovator(); string type = this.getProperty("classification", ""); this.setProperty("item_number", inn.getNextSequence("Design Document")); if (type != null && type.Equals("Design Document")) { this.setProperty("item_number", inn.getNextSequence("Design Document")); } else if (type != null && type.Equals("Engineering Document")) { this.setProperty("item_number", inn.getNextSequence("Engineering Document")); } else if (type != null && type.Equals("Specification Document")) { this.setProperty("item_number", inn.getNextSequence("Specification Document")); } return this;   this is working and I made "item_number" attribute to string and removed required property.
  • Now you understand the concept, it is possible to automatically create and use the sequences. (Note that you cannot create a sequence and call get next sequence in the same Method due to a clash creating and using the sequence) Something similar to: //sequence 1 Item seq1 = inn.newItem("Sequence","get"); seq1.setProperty("name","mySequence_" + this.getProperty("classification","default")); seq1 = seq1.apply(); //if not found, add a new sequence if(seq1.getItemCount()<1) { seq1 = inn.newItem("Sequence","add"); seq1.setProperty("name","mySequence_" + this.getProperty("classification","default")); //update the following to match your requirements// string pre = "pre" seq1.setProperty("prefix",pre); string suf = "suf" seq1.setProperty("suffix",suf); string curVal = "1" seq1.setProperty("current_value",curVal ); string pad = "0" seq1.setProperty("pad_with",pad); int padto = 9 seq1.setProperty("pad_to",padto.ToString()); seq1.setProperty("step","1"); //end of update// seq1 = seq1.apply(); //set the new sequence number on the part must match the new sequence above string s = ""; //adjust padto if using more than 1 digit in curVal for (int i = 0; i<padto; i++) { s+=pad; } s = pre+s+curVal+suf this.setProperty("item_number", s); } else { //if found, get the next sequence number string s = inn.getNextSequence(seq1.getProperty("name","")); //set the new sequence number on the part this.setProperty("item_number", s); }
  • Now I understand the concept.But I am looking for something to configure it rather writing code