I have a form that has code in the postsave event. This code creates a new document in a different database if certain criteria is met within the form. The document is being created fine if I REM out the following line:
doc2.CloseProb = .10
If I leave this line in, the doc gets created in the other database but I get a “Type Mismatch” error on a dependent field. This dependent field basically does a computation of a field named FeePot multiplied by the Closeprob field. The FeePot field is coming in as a string. If I leave the above line OUT and MANUALLY enter the CloseProb percentage, the other field computes as expected and when examining the FeePot field via doc properties it shows as numeric after saving the doc. My question is, how can I pull in the FeePot value as numeric so that my code works with the CloseProb value pre-populated as I’m trying to do?
Thanks in advance!
Dim session As New NotesSession
Dim ws As New NotesUIWorkSpace
Dim db As NotesDatabase 'CSDM DB
Dim db2 As NotesDatabase 'Pipeline DB
Dim uidoc As NotesUIDocument 'doc in CSDM DB
Dim doc2 As NotesDocument 'doc in Pipeline DB
Set db = session.currentdatabase 'CSDM
Set db2 = New NotesDatabase("SMFNT2//SMF", "SMF\\PracticeDev.nsf" )
Set uidoc = ws.CurrentDocument 'Grab current UI document
’ Create Pipeline Entry if Succession Planning is Short Term
If uidoc.FieldGetText("Term") = "Short Term" And uidoc.FieldGetText("TermFlag") = "" Then
Set doc2 = db2.createdocument 'Create document in Pipeline Database
doc2.form = "Practice Dev"
doc2.target = uidoc.FieldGetText("Cname")
doc2.PC = "P"
doc2.RS = "R"
doc2.Orig = uidoc.FieldGetText("NichePrinc")
doc2.Niche = uidoc.FieldGetText("TE")
doc2.Engage = "Succession Planning"
doc2.LOB = uidoc.FieldGetText("Level")
doc2.Idea_1 = uidoc.FieldGetText("Meetg")
doc2.FeePot = uidoc.FieldGetText("ABills")
'doc2.CloseProb = 0.1
'doc2.ProspCont = "Prospect with No Contact"
doc2.Source = "Through CSDM"
doc2.COI = uidoc.FieldGetText("Princ")
doc2.Serv = uidoc.FieldGetText("Princ")
doc2.CL_Addr = uidoc.FieldGetText("SAddr")
doc2.CL_Phone = uidoc.FieldGetText("SAddr_1")
doc2.CL_State = uidoc.FieldGetText("SAddr_2")
Call doc2.Save( True, True )
End If
Subject: RE: Problem with populating a percentage field via script
Thanks for the quick reply and suggestions. However, I am now get a type mismatch when closing the form that contains the code: (Changed line containing FeePot)
Dim session As New NotesSession
Dim ws As New NotesUIWorkSpace
Dim db As NotesDatabase 'CSDM DB
Dim db2 As NotesDatabase 'Pipeline DB
Dim uidoc As NotesUIDocument 'doc in CSDM DB
Dim doc2 As NotesDocument 'doc in Pipeline DB
Set db = session.currentdatabase 'CSDM
Set db2 = New NotesDatabase("SMFNT2//SMF", "SMF\\PracticeDev.nsf" )
Set uidoc = ws.CurrentDocument 'Grab current UI document
’ Create Pipeline Entry if Succession Planning is Short Term
If uidoc.FieldGetText("Term") = "Short Term" And uidoc.FieldGetText("TermFlag") = "" Then
Set doc2 = db2.createdocument 'Create document in Pipeline Database
doc2.form = "Practice Dev"
doc2.target = uidoc.FieldGetText("Cname")
doc2.PC = "P"
doc2.RS = "R"
doc2.Orig = uidoc.FieldGetText("NichePrinc")
doc2.Niche = uidoc.FieldGetText("TE")
doc2.Engage = "Succession Planning"
doc2.LOB = uidoc.FieldGetText("Level")
doc2.Idea_1 = uidoc.FieldGetText("Meetg")
'FP = uidoc.FieldGetText("ABills")
doc2.FeePot = Cdbl(uidoc.FieldGetText("ABills"))
'doc2.CloseProb = 0.1
doc2.ProspCont = "Prospect with No Contact"
doc2.Source = "Through CSDM"
doc2.COI = uidoc.FieldGetText("Princ")
doc2.Serv = uidoc.FieldGetText("Princ")
doc2.CL_Addr = uidoc.FieldGetText("SAddr")
doc2.CL_Phone = uidoc.FieldGetText("SAddr_1")
doc2.CL_State = uidoc.FieldGetText("SAddr_2")
Call doc2.Save( True, True )
End If
I wound up resolving the issue via the following workaround. Once the document was created using the code in the postsave event, the FeePot field being used in one of the form’s calculations was created as text. This is why the error appeared when opening the form. The calculated field was trying to compute the formula using the text created by the script. Since I could not seem to get CDBL to work during the doc creation, I simply modified the computed field’s formula to use @ToNumber(FeePot) so that this covers docs created via script. Not ideal but it works.