jayessj - Tuesday, May 31, 2016 4:35 PM:
Hello all - this is my very first post on here but I am sure it wont be my last :)
is it possible to rename a document using a method?
The reason behind this is because I want the user defined document name to be overwritten by an automated name. I cant use a sequence to do the document naming for me as I have different sequences defined based on classification but can only define one sequence for the document property.
As a result a user will create a document and select the classification and name the document as they wish. On close I would like a method to run that uses the classification to rename the document based on a sequence linked to classification
thanks
kentonv - Friday, June 3, 2016 10:54 AM:
That is definitely possible, and something we have done in our document data.
You will want to create a method that runs at onBeforeAdd that checks the classification, then gets the correct next Sequence value, and applies that to the 'name' property. A quick untested example is below.
Dim inn As Innovator = Me.getInnovator
Dim newName As String = Me.getProperty("name","")
Select Case Me.getProperty("classification")
Case "SomeClass"
newName = inn.getNextSequence("SomeClassSequenceName")
Case "AnotherClass"
newName = inn.getNextSequence("AnotherClassSequenceName")
End Select
Me.setProperty("name",newName)
Return Me
jayessj - Monday, June 20, 2016 3:25 PM:
Kenton
I have tried what you proposed and it works well
Thanks very much
That is definitely possible, and something we have done in our document data.
You will want to create a method that runs at onBeforeAdd that checks the classification, then gets the correct next Sequence value, and applies that to the 'name' property. A quick untested example is below.
Dim inn As Innovator = Me.getInnovator
Dim newName As String = Me.getProperty("name","")
Select Case Me.getProperty("classification")
Case "SomeClass"
newName = inn.getNextSequence("SomeClassSequenceName")
Case "AnotherClass"
newName = inn.getNextSequence("AnotherClassSequenceName")
End Select
Me.setProperty("name",newName)
Return Me