Hi All,
Could anyone kindly advise if there's any working OpportunityHook sample code that I could reference?
I have tried to make up the OpportunityHook by looking at the AddressBookHook and below is my codes
OpportunityHook
----------------
Public Function OpportunityInsert(ByVal MaxApp As Application, ByVal MaxRec As CurrentRecord, ByVal MaxOms As OMS, ByVal ParentHwnd As Long, ByVal rights As Boolean, ByVal reserved As Long) As Boolean
app = MaxApp
cr = MaxRec
cOMS = MaxOms
writeEvent(logPath, logName, "{OpportunityInsert} Current Record ID=[" & cr.GetFieldValue("IDentification") & "]")
'Check DB to determine whether uses Hook or not
If MaxApp.GetCurrentDbName = "NewPremises" Or MaxApp.GetCurrentDbName = "OldPremises" Then
OpportunityInsert = True 'Tells Maximizer to run our code instead if its.
InsertFlag = 1
hWndFrame = ParentHwnd 'Pass Maximizer's Parent Window Handle down.
Oppform = New Contractform()
Oppform.ShowDialog()
Else
OpportunityInsert = False 'Tells Maximizer to run its code instead of ours.
End If
app = Nothing
cr = Nothing
cOMS = Nothing
End Function
Maxdecl:
Public Sub InsertContract()
Dim noErr As Boolean = True
Dim omsVal As String = ""
Try
cr.SetUpdateMode("Delay") 'Wait to write any changes to disk until told to.
omsVal = CType(Oppform, Contractform).title.Text
cOMS.SetOpportunityFieldValue("Opportunity_Objective", omsVal)
Catch ex As Exception
noErr = False
Finally
If noErr Then cr.ExecuteUpdate("True") 'Go ahead and write out changes to disk
End Try
End Sub
I wonder if I could do the Opportunity similar to AddressBook records; coz for CurrentRecord objects we have the initAndCreateRecord function, but for Opportunity (OMS object) I don't see any similar function.
Appreciate if anyone could help.
Thanks!
Original Post