1
Automation Interface, Add-Ins and Tools / Try-Catch in Visual Basic Script VB
« on: August 11, 2016, 01:57:15 am »
Can anyone tell me why this would not work? There is an error " 'Function' expected" appearing in the line with "End Try".
There are basically 3 cases:
1. The GUID of the AttrClassifier is in OwnElems -> set IsValid = true
2. The GUID is not in OwnElems -> set IsValid = false
3. There is no Element with the ID of the Classifier (Catch the Exception thrown in first line of Try-Block) -> set IsValid = true
There are basically 3 cases:
1. The GUID of the AttrClassifier is in OwnElems -> set IsValid = true
2. The GUID is not in OwnElems -> set IsValid = false
3. There is no Element with the ID of the Classifier (Catch the Exception thrown in first line of Try-Block) -> set IsValid = true
Code: [Select]
public function Validate(item)
dim validationResult
set validationResult = new ValidationResult
...
Try
Dim AttrClassifier As EA.Element = Repository.GetElementByID(Attribute.ClassifierID)
Dim guid
Set guid = AttrClassifier.ElementGUID
If THandler.OwnElems.Contains(guid) Then
validationResult.IsValid = true
set Validate = validationResult
Else
validationResult.IsValid = false
set Validate = validationResult
End If
Catch Exception
validationResult.IsValid = true
set Validate = validationResult
Return 'ignore default classifiers and elements without classifier
End Try
end function