On Save Prompt formula

This On Save Prompt formula is executed when a user attempts to save information. The formula returns a prompt to which the user can answer Yes or No.

If the user attempts to submit a water/sewer related service request when the property is not connected, a popup box is to alert the user to check the asset map, as records indicate the customer is not being charged water tariffs.

The check for water/sewer related service request when the property is not connected must be done from the COMP table, not the COMPWSL and COMPSSL tables.

Dim res As Hansen.Core.Result 
dim addrKey = oServiceRequest.Address.AddressKey 
dim oWhereWater As new DBOperativeCollection 
dim oWhereSewer As new DBOperativeCollection 
dim oWaterRequests As Hansen.AssetManagement.IAssetCollection 
dim oSewerRequests As Hansen.AssetManagement.IAssetCollection 
'if request category is "Water" then check if there is a record with comptype = 45 for that address 
'if there is no record then display warning pop up to indicate that the customer is not being charged water tarifs 
myReader.WriteLine("Category = " + oServiceRequest.RequestType.Category.CategoryName) 
myReader.Close() 
If 
Not(oServiceRequest.RequestType.Category Is nothing) and addrKey > 1 
Then If 
oServiceRequest.RequestType.Category.CategoryName = "Water" 
Then 
oWhereWater.Add(new IDOperativeByCommonID("AssetManagement", 
"Asset.Address.AddressKey", ComparisonOperator.Equal, addrKey)) 
oWhereWater.Add(new IDOperativeByCommonID("AssetManagement", 
"Asset.AssetType.AssetType", ComparisonOperator.Equal, 45)) 
oWaterRequests = 
ServerApplication.NewComponent("Hansen.AssetManagement.AssetCollection", oServiceRequest.UserInfo) 
CType(oWaterRequests, IComponent).Load(oWhereWater) 
If 
(oWaterRequests.Count = 0) 
Then 
dim errMsgWater As String = "Please check the asset map as records indicate the customer is not being charged 
water tarrifs" 
Prompt = errMsgWater & Microsoft.VisualBasic.VBCrlf & "Do you want to continue ?" 
End If 
'if request category is "Sewer" then check if there is a record with comptype = 26 for that address 
'if there is no record then display warning pop up to indicate that the customer is not being charged sewer tarifs 
Else If 
oServiceRequest.RequestType.Category.CategoryName = "Sewer" 
Then 
oWhereSewer.Add(new IDOperativeByCommonID("AssetManagement", 
"Asset.Address.AddressKey", ComparisonOperator.Equal, addrKey)) 
oWhereSewer.Add(new IDOperativeByCommonID("AssetManagement", 
"Asset.AssetType.AssetType", ComparisonOperator.Equal, 26)) 
oSewerRequests = ServerApplication.NewComponent("Hansen.AssetManagement.AssetCollection", 
oServiceRequest.UserInfo) 
CType(oSewerRequests, IComponent).Load(oWhereSewer) 
If 
(oSewerRequests.Count = 0) 
Then 
dim errMsgSewer As String = "Please check the asset map as records indicate the customer is not being charged 
sewer tarrifs" 
Prompt = errMsgSewer & Microsoft.VisualBasic.VBCrlf & "Do you want to continue ?" 
End If 
End If 
End If 
Return res