The following code used in the template of UID_ADSaccountManager and occasionally threw very odd exception showing in the screen. If I commented out the highlights then it works fine. I could not see what could be the cause in the template. Can anyone please help me on troubleshooting? Thank you in advance!
Dim f As ISqlFormatter = Connection.SqlFormatter
If CBool(Connection.Variables.Get("FULLSYNC")) = False Then
Select Case ($ManageLevel:Int$)
Case 0:'Unmanaged (do not get data from employee)
Case 1:'Full-Managed (fill all possible fields about employee)
If $FK(UID_Person).IsInActive:Bool$ And $AccountDisabled:Bool$ Then
Value = String.Empty
Else
If $UID_ADSAccountManager$.Length = 0 Then
If $FK(UID_Person).UID_PersonDeputySecond$ <> "" Then
Value = Connection.GetSingleProperty("ADSAccount", "UID_ADSAccount", _
f.AndRelation( _
f.Comparison("AccountDisabled", False, ValType.Bool, CompareOperator.Equal), _
f.Comparison("UID_Person", $FK(UID_Person).UID_PersonDeputySecond$, ValType.String, CompareOperator.Equal), _
f.Comparison("IsPreferredAccount", True, ValType.Bool, CompareOperator.Equal))).ToString()
Else
Value = Connection.GetSingleProperty("ADSAccount", "UID_ADSAccount", _
f.AndRelation( _
f.Comparison("AccountDisabled", False, ValType.Bool, CompareOperator.Equal), _
f.Comparison("UID_Person", $FK(UID_Person).UID_PersonHead$, ValType.String, CompareOperator.Equal), _
f.Comparison("IsPreferredAccount", True, ValType.Bool, CompareOperator.Equal))).ToString()
End If
Else
If $FK(UID_ADSAccountManager).UID_Person$.Equals($FK(UID_Person).UID_PersonDeputySecond$) Then
Value = $UID_ADSAccountManager$
Else
If $FK(UID_Person).UID_PersonDeputySecond$ <> "" Then
Value = Connection.GetSingleProperty("ADSAccount", "UID_ADSAccount", _
f.AndRelation( _
f.Comparison("AccountDisabled", False, ValType.Bool,CompareOperator.Equal), _
f.Comparison("UID_Person", $FK(UID_Person).UID_PersonDeputySecond$, ValType.String, CompareOperator.Equal), _
f.Comparison("IsPreferredAccount", True, ValType.Bool, CompareOperator.Equal))).ToString()
End If
End If
End If
End If
Case Else:
Throw New ViException(#LD("The manage level is unknown.")#)
End Select
End If