I have documents in a folder that have a field AUNID which is filled with the unique id of a specific child doc. On the folder's action bar I have a button which is supposed to open the document related to the AUNID for editing by the user.
When the action button is pressed, it gives the user the following error:
Invalid UNID; UNID must be a 32-digit hex string.
After pressing 'Ok', however, the correct document opens for editing. I have used the debugger and the code is all executing exactly how I anticipate, however this error pops up for what seems like no reason.
Here is my code:
Sub Click(Source As Button)
On Error Goto handleError
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim leaddoc As NotesDocument
Dim action As NotesDocument
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesUIDocument
Set db = s.CurrentDatabase
Set leaddoc = db.UnprocessedDocuments.GetFirstDocument
Set view = db.GetView("(ActionsByLead)")
If (leaddoc.GetFirstItem("AUNID").Text = "") Then
Msgbox ("There is nothing to edit!")
Exit Sub
End If
Dim uid As String
uid = Cstr(leaddoc.GetFirstItem("AUNID").Text)
Set action = db.GetDocumentByUNID(uid)
Call ws.SetTargetFrame("")
Call ws.EditDocument(True, action,,,, False) 'Error occurs on this line according to the debugger.
Exit Sub
handleError:
Resume Next
End Sub
Check the form of the child document that you are opening. I suspect there is something during the load of that document that is causing the error, and it isn't related to the action or the AUNID item on the parent document.
Or try creating a new child document and see if the error appears
Related
I already ask "How to move documents from the original NSF to another NSF?"
(Domino Notes)How to move documents from the original NSF to another NSF?
Now, I still want to ask "How to move the document back to the original NSF?"
I want to make the form that can be moved back to the original database, but there is an error in the command, and cannot be moved back.
The following instructions are written in the buttons of the NOTES form.
How can I modify them?
Sub Click(Source As Button)
Dim ws As New notesuiworkspace
Dim uipr As NotesUIDocument
Dim ask_me As Variant
Set uipr = ws.CurrentDocument
data(0) = "Back original NSF"
data(1) = "Non-person case"
ask_me = ws.Prompt(PROMPT_OKCANCELEDITCOMBO,"Reset Reason","Choose a reason...",data(0),data())
If ask_me = False Then Exit Sub
If uipr.editmode=False Then uipr.editmode=True
If ask_me = data(0) Then
Dim achiveDB As New NotesDatabase("fcpnotesM" , "EFA00B7.nsf")
Dim doc As NotesDocument
Set doc = uipr.Document
Call ChangeField
Msgbox "Change field OK"
Call doc.CopyToDatabase(achiveDB)
Msgbox "Copy success"
Call doc.Remove(True)
Msgbox "Move success"
End If
End Sub
uipr seems to be used before it's defined/asigned
If uipr.editmode=False Then uipr.editmode=True //used here
If ask_me = data(0) Then
Dim achiveDB As New NotesDatabase("fcpnotesM" , "EFA00B7.nsf")
Dim uipr As NotesUIDocument //defined here, but no asignment
I have two document which is original and copy document. When I save copy, original will changes status too.
Follow up by my other question Save copy document and change status field for copy document and original document using lotusscript button. Below are my code.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim activeDoc As NotesDocument
Dim view As NotesView
Dim keys(1) As String
'// Set database and doc
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
keys(0) = doc.PTagNo(0)
keys(1) = "Lock"
Set view = db.GetView("Computer")
vpswd = Inputbox$("Pls input code to save :")
If vpswd = "o" Then
Set activeDoc= view.GetDocumentByKey(keys, True)
If Not activeDoc Is Nothing Then
If activeDoc.PStatus(0) = "Lock" Then
activeDoc.DocumetId = doc.UniversalID
Call activeDoc.ReplaceItemValue("PStatus", "Inactive")
Call activeDoc.Save(True, False)
End If
End If
Call uidoc.FieldSetText("PStatus" , "Active")
Call uidoc.FieldSetText("SaveOptions" , "1")
Call uidoc.Save
Call uidoc.Close
Else
Msgbox "Wrong Code"
Exit Sub
End If
End Sub
I already set variable and successfull saved. When I saved, Copy document is saved and change status to Active, but for Current document which currently with "Lock" status, did not change to "Inactive" status. Can anyone help me? Is there any error that I have made inside coding? Your help really appreciate. Thanks!
I've solved this question. For my problem, I do not set TagNo as my first column. So I need to created new view with two column which is TagNo and Status. Set both column as ascending.
I have a document, and copy of document. I use TagNo as unique ID for both documents.
I also have Status field to differentiate each document which is Active, Inactive, Draft, and Lock. I will explain below my document situation.
Below here are my document with two field; Tag No = PTagNo; Status = PStatus. The situation as below.
For Original document, the status is set Active. When copy is created, Original document will change to Lock, And Copy document status change to Draft. (For this I already achieve.)
After done editing, I will change status for Draft document and Original document. This happen when I save Draft document as "Complete". My Draft document will be Original document while my Original document will be Archived document. So for my Draft document, status will change to Active while Original Document, status will change to Inactive.(Not achieve yet).
I paste my save code as below.
Save and Complete
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim activeDoc As NotesDocument
Dim view As NotesView
Dim keys(1) As String
'// Set database and doc
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
keys(0) = doc.PTagNo(0)
keys(1) = "Lock"
Set view = db.GetView("Computer")
vpswd = Inputbox$("Pls input code to save :")
If vpswd = "o" Then
Set activeDoc= view.GetDocumentByKey(keys, True)
If Not activeDoc Is Nothing Then
If activeDoc.PStatus(0) = "Lock" Then
activeDoc.DocumetId = doc.UniversalID
Call activeDoc.ReplaceItemValue("PStatus", "Inactive")
Call activeDoc.Save(True, False)
End If
End If
Call uidoc.FieldSetText("PStatus" , "Active")
Call uidoc.FieldSetText("SaveOptions" , "1")
Call uidoc.Save
Call uidoc.Close
Else
Msgbox "Wrong Code"
Exit Sub
End If
End Sub
So I use GetDocumentByKey for field ptagno but it show error "Object variable not set". Did I use wrong function?. Any help will be appreciated. Thanks!
The variable ptagno has not been set - therefore the "Object variable not set" error. You need to read the value from the field PTagNo and assign it to the ptagno variable - or use it directly. For instance like this:
Set activeDoc= view.GetDocumentByKey(uidoc.FieldGetText("PTagNo"))
I want to put a form ( document ) to EditMode = false; So, when the form is opened, I want to cannot modify any fields etc until I press a button that puts the doc. in EditMode = true.
My code is smth like this:
Sub Initialize
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = ws.CurrentDocument
'Set doc = uidoc.Document
uidoc.EditMode = False
End Sub
I choose to code in the Initialize method of the Form...
But it doesn't work and it gives me a message like: " Document comand is unavailable" . Please help, I will appreciate, thank you.
As a general rule of thumb, the Initialize event should not be used in forms. One reason for this is that the form has not necessarily finished loading everything by the time that Initialize runs.
This code should be placed in the QueryOpen event.
Another best practice is to NOT use NotesWorkspace.CurrentDocument to get a handle to the current form and instead use the Source parameter passed into the QueryOpen event. NotesWorkspace.CurrentDocument should only be used in agents and other places where the form is not already in context. Calling NotesWorkspace.CurrentDocument while the current document is already in context can cause strange behavior in Notes.
Here's some code that should work:
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
If (Not Source Is Nothing) Then Source.EditMode = False
End Sub
I got an error 'Document command is not available' when the program hits the uidoc.Copy line. I have researched this error message. But all I get is only if it has anything to do with Edit Mode and I am not using that at all here.
Sub Click(Source As Button)
' ===========================================================
' Get common username, mail server, and mailfile information
to be used on ComposeDocument method
Dim session As New NotesSession
Dim reg As New NotesRegistration
Dim user As String
reg.RegistrationServer = "Test"
user = session.CommonUserName
Call reg.GetUserInfo(user, _
mailserver$, _
mailfile$)
' ======================================================================
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Call uidoc.GotoField("QSContactEMail")
Call uidoc.SelectAll
Call uidoc.Copy
Set uidoc = workspace.ComposeDocument _
(mailserver$, mailfile$, "Memo")
Call uidoc.GotoField("Subject")
Call uidoc.Paste
End Sub
You don't need to use copy and paste to transfer values from one document to another. You can directly assign those values using document objects.
There are several methods to do this- here is one that is similar to yours. Replace everything below the second line with this:
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument, newuidoc as NotesUIDocument
Set uidoc = workspace.CurrentDocument
Set newuidoc = workspace.ComposeDocument _
(mailserver$, mailfile$, "Memo")
Call newuidoc.FieldSetText("Subject", uidoc.FieldGetText("QSContactEMail"))
End Sub
Check to see if you have a field called $KeepPrivate set to "1". It will prevent copying.
The error can also happen if nothing is selected. Try STOP just before the line and make sure it is highlighted.
There are also other conditions listed here:
http://www-01.ibm.com/support/docview.wss?uid=swg21094450