I have a save button in my lotus notes. My save button will execute some process in lotusscript. I will explain what document related to my save process.
Now I have a document from main view with status "Active", I called it "current" document.
So the process will start edit copy document and save it. Copy document status will change from "Draft" to "Active", and current document will change from "Active" to "Inactive". That means, Copy document will be new current document. Then, Inspection Report status will change to "Complete".
Below is my lotusscript button code:
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
'//Set lookup view for current document
keys(0) = doc.PTagNo(0)
keys(1) = "Lock"
Set view = db.GetView("TagNo")
'//Set lookup view for "Inspection" document
pckeys(0) = doc.PTagNo(0)
pckeys(1) = doc.PBatchNo(0)
pckeys(2) = "Incomplete"
Set pcview = db.GetView("BatchPCInspection")
answer% = Messagebox("Save PC Inspection?", 4,"Confirmation")
If Not answer% = 6 Then
Exit Sub
Else
'//Make changes for "Inspection" document
Set comdoc = pcview.GetDocumentByKey(pckeys, True)
If Not comdoc Is Nothing Then
If comdoc.AStatus(0) = "Incomplete" Then
comdoc.DocId=doc.UniversalID
comdoc.ATagNo = doc.PTagNo
comdoc.ADept= doc.PDept
comdoc.AUserName= doc.PUserName
comdoc.AStatus="Complete"
Call comdoc.Save(True, False)
End If
End If
'//Make changes for current document become Inactive
Set activeDoc = view.GetDocumentByKey(keys, True)
If Not activeDoc Is Nothing Then
If activeDoc.PStatus(0) = "Lock" Then
activeDoc.DocumetId = doc.UniversalID
activeDoc.PStatus = "Inactive"
Call activeDoc.Save(True, False)
End If
End If
'//Make changes for "Copy" document become Active
Call uidoc.FieldSetText("PStatus" , "Active")
Call uidoc.FieldSetText("SaveOptions" , "1")
Call uidoc.Save
Call uidoc.Close
End If
End Sub
So my question now, how can I convert this lotusscript code to javascript code? Because lotusscript will not run in web browser, so I surely need to convert this to javascript. Anyone know any documentation or way on how to convert this lotusscript button to javascript button. Any help will be appreciated!
Simple answer: there is no easy way to convert your LotusScript to JavaScript code as there are no LotusScript- Classes in JavaScript.
You can "mimic" the code when using XPages, but then your complete code needs to be XPage- based and not "classic web development" anymore.
If you want to stay with "classic" web development (Forms, views, etc.) and not XPages, then you need to separate your code in frontend and backend and put the backend code in an agent that is called via frontend.
So you need to completely restructure your code, rewrite most of it and take out the "frontend- interaction" to be made with JavaScript....
You need an interface between frontend and backend (you could use WebQueryOpen and WebQuerySave- Agents, but it might not be enough), most probably need Ajax- Calls and need to know how to return JSON or HTML with an agent.
Again: this question is not answerable here at stackoverflow as it needs to much expertise and whoever is able to answer this is probably a consultant who rather would sell you the solution than give it away for free.