aib_it
asked on
Lotus script
HI;
I have a Helpdesk DB when a case is raised a case number is assigned automatically from a network file. I have not found any way to make it auto via script only. Now some times when network is slow or due to time out the auto number is not picked when a new case is raised.I want either the field be made in such way that it has to wait unless the number is picked or to be automated via lotus script so i may not need the network file. I have pasted the script here. Please help.
Thanks
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim fileNum As Integer
Dim fileName As String
Dim NrCrt As Long
Dim NewNrCrt As Long
fileNum% = Freefile()
fileName$ = "\\server\uniqueNo\SRegNo. txt" 'This is the path to the file that keeps the current number
'If is new doc assign a new number
If source.IsNewDoc Then
'Open for reading the file, read the value then close the file
Open fileName$ For Input Lock Read Write As fileNum% '
Input #fileNum%,NrCrt
Close fileNum%
NewNrCrt=NrCrt+1 'Increment the value
'Open for writing the file, write the value then close the file
Open fileName$ For Output Lock Read Write As fileNum%
Write #fileNum%,NewNrCrt
Close fileNum%
If Isnull(NewNrCrt) Then
Msgbox("Can't generate the registration number ! Please check the path to the file: " & fileName$ )
End If
If Source.FieldGetText("Depar tment")="" Then
Msgbox "Please enter the required values such as Department and phone number"
continue=False
Exit Sub
End If
Call source.FieldSetText("sRegN o","ITHELP -" & Str$(NewNrCrt)) 'Complete the current number in the form
End If
End Sub
I have a Helpdesk DB when a case is raised a case number is assigned automatically from a network file. I have not found any way to make it auto via script only. Now some times when network is slow or due to time out the auto number is not picked when a new case is raised.I want either the field be made in such way that it has to wait unless the number is picked or to be automated via lotus script so i may not need the network file. I have pasted the script here. Please help.
Thanks
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim fileNum As Integer
Dim fileName As String
Dim NrCrt As Long
Dim NewNrCrt As Long
fileNum% = Freefile()
fileName$ = "\\server\uniqueNo\SRegNo.
'If is new doc assign a new number
If source.IsNewDoc Then
'Open for reading the file, read the value then close the file
Open fileName$ For Input Lock Read Write As fileNum% '
Input #fileNum%,NrCrt
Close fileNum%
NewNrCrt=NrCrt+1 'Increment the value
'Open for writing the file, write the value then close the file
Open fileName$ For Output Lock Read Write As fileNum%
Write #fileNum%,NewNrCrt
Close fileNum%
If Isnull(NewNrCrt) Then
Msgbox("Can't generate the registration number ! Please check the path to the file: " & fileName$ )
End If
If Source.FieldGetText("Depar
Msgbox "Please enter the required values such as Department and phone number"
continue=False
Exit Sub
End If
Call source.FieldSetText("sRegN
End If
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No, the users are going to kill you :)
It's not at all difficult from version 6, when IBM introduces Lock method on NotesDocument.
Use special document in a special view.
In that doc create a field where you'll store the last number.
All this, along with the code for the function that gets the new number is described in the URL I posted. Read it...
It's not at all difficult from version 6, when IBM introduces Lock method on NotesDocument.
Use special document in a special view.
In that doc create a field where you'll store the last number.
All this, along with the code for the function that gets the new number is described in the URL I posted. Read it...
ASKER
Yea correct but the problem is that now its difficult to do all from the beginning, i wanted the current one to be reliable.
What from the beginning?
I suppose you have a function that does all that with reading/incrementing the file and returns the new sequence.
All you have to do is change it. As I said, the code is already there.
Start, step by step, and ask when you get stuck... Post the existing code, I'll help you...
I suppose you have a function that does all that with reading/incrementing the file and returns the new sequence.
All you have to do is change it. As I said, the code is already there.
Start, step by step, and ask when you get stuck... Post the existing code, I'll help you...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI Mbonaci;
Thanks for all the replies, due to holidays here i could not reply. Can you please modify the code i provided although if you check the following exact code for sequence generator. In the last line its mentioned that if the sequence is not geting generated a message should get displayed.
If you are suggesting auto sequence instead of network file please paste the modified code so i can paste the same in querysave section of the designer.
:) thanks
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim fileNum As Integer
Dim fileName As String
Dim NrCrt As Long
Dim NewNrCrt As Long
fileNum% = Freefile()
fileName$ = "\\server\uniqueNo\SRegNo. txt" 'This is the path to the file that keeps the current number
'If is new doc assign a new number
If source.IsNewDoc Then
'Open for reading the file, read the value then close the file
Open fileName$ For Input Lock Read Write As fileNum% '
Input #fileNum%,NrCrt
Close fileNum%
NewNrCrt=NrCrt+1 'Increment the value
'Open for writing the file, write the value then close the file
Open fileName$ For Output Lock Read Write As fileNum%
Write #fileNum%,NewNrCrt
Close fileNum%
If Isnull(NewNrCrt) Then
Msgbox("Can't generate the registration number ! Please check the path to the file: " & fileName$ )
End If
Thanks for all the replies, due to holidays here i could not reply. Can you please modify the code i provided although if you check the following exact code for sequence generator. In the last line its mentioned that if the sequence is not geting generated a message should get displayed.
If you are suggesting auto sequence instead of network file please paste the modified code so i can paste the same in querysave section of the designer.
:) thanks
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim fileNum As Integer
Dim fileName As String
Dim NrCrt As Long
Dim NewNrCrt As Long
fileNum% = Freefile()
fileName$ = "\\server\uniqueNo\SRegNo.
'If is new doc assign a new number
If source.IsNewDoc Then
'Open for reading the file, read the value then close the file
Open fileName$ For Input Lock Read Write As fileNum% '
Input #fileNum%,NrCrt
Close fileNum%
NewNrCrt=NrCrt+1 'Increment the value
'Open for writing the file, write the value then close the file
Open fileName$ For Output Lock Read Write As fileNum%
Write #fileNum%,NewNrCrt
Close fileNum%
If Isnull(NewNrCrt) Then
Msgbox("Can't generate the registration number ! Please check the path to the file: " & fileName$ )
End If
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI sjef_bosman;
We don't have replicas its only a single DB.Now i am little confused. Creating agent is not a difficult task but altering the structure of the DB is now difficult, becuase the HELP desk DB is now used for more than 2 years with alot of requests inside. So the only way i can see is that the sequence which is currently picked from a network file that needs to be made in such a way that if a user is accessing this DB from any other subnet (DB willbe still on the main server) and incase a timeout occurs the document should popup the message "Can't generate the registration number ! Please check the path to the file" and when user is trying to save it again the number should get picked up.
Or
Sequence should be prepared in such way that if the doc is saved the number should get generated automatically using the script without connecting to network file.
I hope you guys will help me :)
Thanks
We don't have replicas its only a single DB.Now i am little confused. Creating agent is not a difficult task but altering the structure of the DB is now difficult, becuase the HELP desk DB is now used for more than 2 years with alot of requests inside. So the only way i can see is that the sequence which is currently picked from a network file that needs to be made in such a way that if a user is accessing this DB from any other subnet (DB willbe still on the main server) and incase a timeout occurs the document should popup the message "Can't generate the registration number ! Please check the path to the file" and when user is trying to save it again the number should get picked up.
Or
Sequence should be prepared in such way that if the doc is saved the number should get generated automatically using the script without connecting to network file.
I hope you guys will help me :)
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What I meant with getting Save Conflicts is that, once you activate document locking in a database, you have to be aware of the fact that ALL edit-actions are locking. We developed a database with main-response documents, originally without locking and on one server (they said). After one month, they introduced a 2nd server and Save conflicts started popping up. We thought to use those nice Locking features, but after activating that we got even more conflicts per day. When a response document was updated, they wanted the main document also updated. The update could be manual, but also by an agent in the background. In short, we had lots of trouble correcting the design flaws that weren't a problem at the start, of which we were told that there were to be neglected (we told them it would be a problem if...) but proved to be a real PITA in the end.
The agent-idea would be:
- a single agent
- running in ONE replica only
- runs on all new and modified documents
- if a (new) document with an empty sequence number is found, it adds a sequence number
Since there's only one agent, and documents without a sequence number cannot be edited (QueryOpen or QueryModeChange), you don't need locking. Drawback: you have to wait 5-15 minutes, till the agent passed by.
The agent-idea would be:
- a single agent
- running in ONE replica only
- runs on all new and modified documents
- if a (new) document with an empty sequence number is found, it adds a sequence number
Since there's only one agent, and documents without a sequence number cannot be edited (QueryOpen or QueryModeChange), you don't need locking. Drawback: you have to wait 5-15 minutes, till the agent passed by.
How the agent knows which number it should give to the document?
It could use the same technique of the external file, as in the current QuerySave. Or from a profile document.
To avoid potential problems with locking that Sjef mentioned you should do all that I mentioned in a new database which you'll create and simply change the line of code of GenSeqNo:
Set db = session.CurrentDatabase
with these lines:
Set db = s.GetDatabase("YourServerN ame", "DatabaseRelativePath")
If db Is Nothing Then
Messagebox "Lock db doesn't exist"
End If
Set db = session.CurrentDatabase
with these lines:
Set db = s.GetDatabase("YourServerN
If db Is Nothing Then
Messagebox "Lock db doesn't exist"
End If
ASKER
Thanks guys for all the posts, i have created the copy of the current DB and now going to start the testing, i hope every thing may work as expected. :)
Really appreciate your replies.
Thanks
Really appreciate your replies.
Thanks
Is this resolved?
ASKER
Sorry guys, it is still in pending list as i have alot of other tasks to be completed. I will shortly let you guys know of the result.
Kind Regards
Kind Regards
ASKER
let this case be open for some time,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Could not got the proper solution for which i was looking.
ASKER
Thanks for the replies.
I agree its difficult to get the number sequence via lotus script. The sequence which i have i want to make sure that document must get a number, i mean that if connection is not ok to contact the network shared folder then the system must wait unless the document is assigned a number. Is this kind of restriction applicable.
Thanks