wilsonphilips
8th September 2005, 18:16
Hi Everybody:
Some one if I can Use the AFS Syntax in a Lotus Notes Application?.
Like VB, can I use AFS?
Thanks.
Wilson
theierm
19th September 2005, 11:34
You can use AFS from Lotus Script (similary to VB script). For example, I have created a button which read some data about item from BaaN - here is the script
Sub Click(Source As Button)
Dim FieldValue As String
Dim SessionName As String
Dim FieldName As String
Dim FunctionPomCall As String
Dim PomField As String
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim docProfile As NotesDocument
Dim session As New NotesSession
Dim ItemSave As String
Dim ItemFound As String
Set uidoc = workspace.CurrentDocument
If Not uidoc.EditMode Then
Messagebox("Document has to be in edit mode")
Exit Sub
End If
Set db = session.CurrentDatabase
Set docProfile = db.GetProfileDocument("wProfileUser", session.UserName)
If docProfile Is Nothing Then
Messagebox("You do not have set your profile")
Exit Sub
End If
pomBaanFile = docProfile.GetItemValue("UPBaanFile")
If pomBaanFile(0) = "" Then
Messagebox("You do not have set your profile") Exit Sub
End If
Set BaanObj = CreateObject("Baan4.Application." & pomBaanFile(0))
BaanObj.Timeout = 5
If BaanObj Is Nothing Then
Exit Sub
End If
SessionName = "tiitm0501m000"
FieldName = "tiitm001.item"
ItemSave = uidoc.FieldGetText("Item")
FieldValue = ItemSave
FunctionPomCall = "stpapi.put.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & FieldName & Chr(34) & ", " & Chr(34) & FieldValue & Chr(34) & ")"
BaanObj.ParseExecFunction "ottstpapihand", FunctionPomCall
FunctionPomCall = "stpapi.find(" & Chr(34) & SessionName & Chr(34) & ")"
BaanObj.ParseExecFunction "ottstpapihand", FunctionPomCall
FieldName = "tiitm001.item"
FieldValue = String(16, " ")
FunctionPomCall = "stpapi.get.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & FieldName & Chr(34) & ", " & Chr(34) & FieldValue & Chr(34) & ")"
BaanObj.ParseExecFunction "ottstpapihand", FunctionPomCall
ItemFound = GetValueFromStapiGet(BaanObj.FunctionCall, SessionName, FieldName)
If ItemFound <> ItemSave Then
Goto Nenalezena
End If
'Naplnovani poli
FieldName = "tiitm001.csgs"
FieldValue = String(10, " ")
FunctionPomCall = "stpapi.get.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & FieldName & Chr(34) & ", " & Chr(34) & FieldValue & Chr(34) & ")"
BaanObj.ParseExecFunction "ottstpapihand", FunctionPomCall
PomField = GetValueFromStapiGet(BaanObj.FunctionCall, SessionName, FieldName)
Call uidoc.FieldSetText("Csgs", Trim(PomField))
FieldName = "tiitm001.dsca"
FieldValue = String(30, " ")
FunctionPomCall = "stpapi.get.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & FieldName & Chr(34) & ", " & Chr(34) & FieldValue & Chr(34) & ")"
BaanObj.ParseExecFunction "ottstpapihand", FunctionPomCall
PomField = GetValueFromStapiGet(BaanObj.FunctionCall, SessionName, FieldName)
Call uidoc.FieldSetText("Dsca", Trim(PomField))
FieldName = "tiitm001.seak"
FieldValue = String(16, " ")
FunctionPomCall = "stpapi.get.field(" & Chr(34) & SessionName & Chr(34) & "," & Chr(34) & FieldName & Chr(34) & ", " & Chr(34) & FieldValue & Chr(34) & ")"
BaanObj.ParseExecFunction "ottstpapihand", FunctionPomCall
PomField = GetValueFromStapiGet(BaanObj.FunctionCall, SessionName, FieldName)
Call uidoc.FieldSetText("RemarkID", Trim(PomField))
Call uidoc.GotoField("Cuno")
Goto konec
Nenalezena:
Messagebox("Item not found")
konec:
BaanObj.ParseExecFunction "ottstpapihand", "stpapi.end.session(" & Chr(34) & SessionName & Chr(34) & ")"
BaanObj.Quit
Call uidoc.Refresh
End Sub