Subject: Answering…
Carl,
I used to use this field as it would be used, with the Lotus System adding the name of the form. But now, I see that it isnt’ working and I force the Notes to put and save the formulary name.
I tried a lot of thing and scripts, on the QuerySave I got error, cause I was forcing the notes save on this event. Now my code is on PostSave and on the action button.
I’ll post here the codes. I got an idea: at my action button, after it does what it has to do, I try to call an agent, that uses formula, to set up the name of the formulary after its saving. But I have no result, again.
PostSave code:
Sub Postmodechange(Source As Notesuidocument)
dim wks as new notesuiworkspace
dim doc as notes document
set Source = wks.CurrentDocument
set doc = Source.Document
if not (docativo is nothing) then
doc.Form = "Oportunity"
call docativo.save(true,true)
exit sub
End Sub
Action Button Code:
Dim s As New NotesSession
Dim doc As NotesDocument
Dim uiDoc As NotesUIDocument
Dim docui As NotesUIDocument
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim docativo As NotesDocument
Dim dbcur As NotesDatabase
Dim prospecto As Variant
Set dbCur = s.CurrentDatabase
Set uiDoc = Workspace.CurrentDocument
Set docui = Workspace.CurrentDocument
askme = workspace.Prompt (PROMPT_YESNO, "Change Status", "Do you really want to change the status of this document")
If askme = 1 Then
Set docativo = New NotesDocument(dbCur)
'Set docativo = workspace.ComposeDocument(“”,“”,“Opotunity”)
docativo.Form = "frmOportunidade"
docativo.prospect_1 = Cstr(uiDoc.FieldGetText("prospect_1"))
docativo.MeuID = Cstr(uiDoc.FieldGetText("DocID"))
docativo.MeuDocID = Cstr(uiDoc.FieldGetText("MeuDocID"))
docativo.fatherID = Cstr(uiDoc.FieldGetText("fatherID"))
docativo.name= uiDoc.FieldGetText("name")
[…]
Call docativo.Save(True,False)
If Not (docativo Is Nothing) Then
Dim agent As NotesAgent
Set db = s.CurrentDatabase
Set agent = db.GetAgent("Change Value")
Call agent.Run
If agent.Run = 0 Then
Msgbox " Agent ran!"
Else
Msgbox "Agent doesn't ran"
Call docativo.Save(True,True)
End If
End If
uiDoc.EditMode = True
Call uiDoc.FieldSetText("prospect","0")
Call uiDoc.Save
Call uiDoc.Close
Set docui = workspace.EditDocument( True,docativo)
Msgbox "Change was successfully performed."
Elseif askme = 0 Then
Exit Sub
End If
erro:
'Msgbox "*** Error at button Prospect to Oportunity(CLICK) - Error Number: " + Cstr(Err) + ". Error: " & Error & " line " & Erl
'Exit Sub
End Sub