There is an application on Lotus notes 5. The getdocumentbykey function is not working if the view is open. If some other view is open or if the Database is closed then the function is working correctly and finding the document. How can we make it work even if the view is open? I have given the part of the code below. Thank you.
BillNo2 = cdoc.fieldgettext("Bill_No2")
Set view = db2.GetView("Bill No.")
Set doc = view.getdocumentbykey(BillNo2)
If Not doc Is Nothing Then
doc.DOdone = "Done"
doc.LorryNo = cdoc.fieldgettext("Lorry_No")
doc.TripNo = cdoc.fieldgettext("Trip_No")
Call doc.save(True, True)
End If
While debugging, its skipping the line "If Not doc is Nothing" and ends the loop even there is document. The same code works fine if the view is not open. Kindly help me. Thanks.
Working backwards, if fieldGetText is not returning what you expect, your getDocumentByKey call will fail. Have you checked the value of BillNo2 in the debugger prior to the call?
Working backwards further, a reason that fieldGetText would not return what you expect would be that cdoc isn't what you expect. How are you running this code? And what is the code for setting cdoc? Since you use fieldGetText, I presume it is a NotesUIDocument, and guessing from the name I'll bet you're getting it from NotesUIWorkspace.currentDocument. Perhaps the currentDocument in the context that your code is running isn't quite what you expect. I.e., if your code is running in the context of the view, instead of in the context of the document that you're reading from, I would not expect it to work.
This sounds like a bug, which is entirely possible given that we're talking about a version that came out 13 years ago. But a few things to check first:
Make sure the first column of the Bill No. view is sorted.
Make sure the view is not a private view type.
If neither of those are true, or you can't change that view for business reasons, I think Anders's suggested workaround of using a hidden view is an excellent idea and should solve the problem.
Related
I am currently learning CouchDB and using the O'Reilly book as a guide to get started. I've been following it pretty thoroughly, however, upon working with Sofa, the book requires me to inspect what happens when we hit 'Save' on our edit template. The book says that I should see a success response (uses Firebug the button triggers the Put request), however, instead I get a "
{"error":"not_found","reason":"missing shows function new.html on design doc _design/sofa"}"
Now I only started reading this week and I know the answer might be obvious, but if someone could at least point me in the right direction (where in Sofa to add, fix a bug, patch) that would be great.
My initial guess is that I need to add a "new" shows function, but I just wanted some advice before I delve into this wild goose chase.
sorry if this is a noob question.
{"couchdb":"Welcome","uuid":"4d9b6082e16607a33dcbfdffb57503b5","version":"1.6.1","vendor":{"version":"1.6.1","name":"The Apache Software Foundation"}}
Downloaded the newest version of Sofa from (https://github.com/jchris/sofa)
How to resolve the issue
The issue is that the page is being accessed from:
http://127.0.0.1:5984/myblogdb/_design/sofa/_show/edit
Access it instead from:
http://127.0.0.1:5984/myblogdb/_design/sofa/_show/edit/
(Your database name may differ from 'myblogdb'). Note the trailing backslash.
Explanation of why a show function called "new" is not necessary:
Take the following query to a show function:
http://127.0.0.1:5984/myblogdb/_design/sofa/_show/edit/This-is-a-second-post
This will call the function in edit.js and pass in the document with an _id of This-is-a-second-post, if such a document exists. If the document doesn't exists, as in the case of
http://127.0.0.1:5984/myblogdb/_design/sofa/_show/edit/new.html
Then edit.js sets up the data object passed to Mustache.to_html to have the correct fields for a new post.
Why it breaks in your case
When the edit show function is accessed via
http://127.0.0.1:5984/myblogdb/_design/sofa/_show/edit
The relatives paths to the scripts no longer work.
Then the script defined in edit.html is no longer correct.
As a result, the submit handler
$("form#new-post").submit(function() { ...
is no longer called. If it were called it would return false at the end, which prevents new.html from being POSTed.
Since it is not called, new.html ends up being POSTed, and that redirects the browser to
http://127.0.0.1:5984/myblogdb/_design/sofa/_show/new.html
which points to a non-existent show function, resulting in the error message you are seeing.
I was playing around with run With Document Context almost the whole day. Maybe someone can help to find me a feasible solution.
If i run the agent in before page load / before render response / query Open Document event i am able to pass values back to the xpage without saving the document. I tried also to save the document but it didnt help.
Beside these two events i didn't find a way to call the agent and bring the values from the lotus notes agent back. Can anybody think of an event that would work?
Calling an agent does work from anywhere you can call SSJS. Some considerations are on my blog.
However there is one big, big caveat: when you try to use a document (saved or unsaved) that is bound to a datasource in your current XPage, then the values in the datasource will overwrite the changes in the backend document. This could be your issue?
As David suggests: use SSJS & Java. It is less work than you might fear and you can pay down some technical debt
How about just creating a new Domino document, put the fields on it that you want to send, call your agent, and then get back those fields. Then populate whatever you need to on the XPage (getComponent("name").setValue(value).
There is no need to save this temporary document and it will just end up going away when your code runs.
In a production application that I have developed sometimes I get an error saying .getDocument() is null. I have added checks in my code that traps an error if this happens. And the strange thing is that the XSPDocument seams to be OK.
Any other ideas how to debug the cause of this?
========================================================
Edit
The lower parts of the application is a simple database, create an assignment it gets status new
change the status to ongoing thru a button. Add information in text, date and numberfields, no Richtext, no attachments.
The user can switch to another xpage to send this document is an pdf attachment in an email.
The user can save the document as a draft
When they are done the click on an approve button and this button will set the status to approved. Save the document and send it as an pdf to an email adress
The problem ocurrs both on the Save button and on the approve button.
.getDocument from the xsp document is null the xspdocument.getNoteID return an ID
I can do replaceitemvalue on the xsp document.
It never happens on new documents only existing what I have seen
It feels like the comment from David that the backend doc is dropped/recycled
we experienced the same getDocument() problem recently. Finally we found a root cause: two different XPages were loaded simultaneously via iFrames. One of those XPages produced run-time error randomly, in 25% of cases. A sort of conflict in JSF model in context of single session.
solution: viewState="nostate"
not sure if it helps in your case, but this option resolved a lot of problems in our applications. It was introduced in 8.5.3. And it should be especially useful for so called XAgents.
Hard to give a hint without knowing more about everything else, but I remember having seen this as well. Just a few ideas:
Is XSPDocument.getNoteID() pointing to a valid Document if this happens?
Is it maybe pointing to a different doc than what you expected?
Could there be some kind of dynamic change of datasources going on?
Maybe some kind of timeout so that the server all of a sudden forgot who you are (in rare cases this happens to me)?
Lothar/edcom
It would be helpful to have a few more details. I assume that the document has previously been saved and it's not a new note?
You're not trying to put the actual document object inside a scoped variable are you? That would be bad as that would be pretty toxic. Without knowing more I would think this could be the case. The backend document has been garbage collected.
I have a ribbon button on the case entity that updates a single two-option field on the form via javascript. When this is used on a case that has been resolved/closed it returns an error as the form is now read only.
Is there a way in javascript that I could get it to re-activate the form, change the field and then put it back to the way it was before? I have tried to force the change on the form but even if i manage to make it appear that you can save it, it will return the error as the form record is still counted as de-activated, even though you can change the fields
Thanks
You should be able to use a SOAP call for this, its a little involved, I would suggest starting here. You have to generate XML that represents the request, the link provides some tools to do this.
I believe you will need to issue JavaScript versions of SetStateRequest (to open) and CloseIncidentRequest (to close).
On the other hand, which is a different approach entirely, is to disable the button when the record is deactivated, then users have to manually renable the record make the change and close again. This is closer to 'working with the system' which I have touched upon here, its a different situation but the principle still applies.
I inherited an very old application that I am in the process of updating it (I know, we should have rewrote it in VS 2008, but we purchased a company, which is how I was stuck with the relic). Using UpdateData(TRUE) to retrieve the changes made in the dialog controls, nothing is being updated. I have an edit control, with an integer variable, and an edit control with a string variable, assigned using the class wizard. Upon pressing the OK button, the UpdateData(TRUE) is executed to retrieve the new values from the disalog.
I seem to remember having a similar problem back when VS C++ 6.0 first came out, but have not used it since VS 2003 and C# became prevalent.
Thanks for any help in advance!
Bill
Check the DoDataExchange() method. It should have the logic for writing data to or reading it from the controls. If the programmers used the default implementastion, then there will be a DDX_... macro for each control that is being read/written. Just look at any other MFC dialogs (in your code or google) to see how the DDX commands should be written if they are missing.
Alternatively, if it's only 1 or 2 values you can easily just get the control and read it directly if you don't mind doing validation etc yourself. Get the ID of the control from the form designer and use something along the lines of:
CEditWnd *pWnd = GetDlgItem(ID_THECONTROL);
CString newValue = pWnd->GetWindowText();
...
You'll need to look at the content of the DoDataExchange method and see what it is doing. There is not sufficient information here to tell what could be going wrong other than that.