Domino XPages R8.5.3 FP6, any browser. No problems on R9+.
The error occurs on some existing documents while saving, but not on all. There's a rich text field in a database that's being migrated to XPages. New documents work, but on some older documents there is an error. The client won't install R9 right now, so we have to find some sort of solution.
What we did: the document is checked before it's opened by XPages in the browser. The treatment: the Body field is converted to MIME. Once that's done, the error is gone.
if(SystemData.getNotesBuildVersion()<400) { // <R9
if(doc.hasItem("Body") && !doc.hasItem("Converted")) {
var tmpdoc= database.createDocument();
doc.getFirstItem("Body").copyItemToDocument(tmpdoc);
doc.removeItem("Body");
doc.save(true, false);
tmpdoc.convertToMIME(3, 0);
tmpdoc.getFirstItem("Body").copyItemToDocument(doc);
doc.replaceItemValue("Converted", "1");
doc.save(true, false);
}
}
It's not a perfect solution, but luckily in most cases the text formatting in the rich text field isn't very important.
Hope it helps someone.
Related
I'd like to force saving data of NotesXSPDocument to prevent creating conflict document in case users are opening the same document.
For NotesDocument, there is a option in NotesDocument.save method but not in NotesXSPDocument.save.
For instance, when clicking 'save' button, I think the next codes meets my requirement. However I have lots of custom control and fields, it is not a smart solution... Is there any other good solution?
var doc:NotesDocument = document1.getDocument();
doc.replaceItemValue("Field1", data1);
doc.replaceItemValue("Field2", data2);
doc.replaceItemValue("Field3", data3);
.....
doc.save(true);
You can save a datasource as described here: https://openntf.org/XSnippets.nsf/snippet.xsp?id=save-datasource-fire-querysavepostsave-events
I'm trying to close NotesUIDocument but there is always a pop-up dialog to ask whether to save or send the document. I know how the trick in LotusScript, which is modify 'SaveOptions' to '0', but have no idea how to access 'SaveOptions' by Java. I also think of a workaround that save the ui document, close it and delete the corresponding document in database. But surprisingly the dialog shows again even though the document has been saved.
Here is part of my codes:
NotesUIWorkspace ws = new NotesUIWorkspace();
NotesUIElement element = ws.getCurrentElement();
NotesUIDocument doc = (NotesUIDocument) element;
doc.save();
doc.close();
Is there anyone that knows how to make it work in Java? Thanks!
I found the trick in Java. Here is the codes:
// close ui document without saving
NotesBEDocument docbe = doc.getBEDocument();
docbe.setItemValue("SaveOptions", "0");
docbe.setItemValue("MailOptions", "0");
doc.close();
docbe.removeItem("SaveOptions");
docbe.removeItem("MailOptions");
Both SaveOptions and MailOptions need to be modified in order to hide the dialog.
In Client Notes programming there is an action button:
#MailSend(Destinatari;"";"";"Subject";"";"";IncludeDoclink])&
#Command([FileSave])&#Command([FileCloseWindow])
I want to make a similar action in my xpage application which works both in XPiNC and web.
My sendto field is a DjTextarea which can have multiple values.
I tried to create a simple action for my button from xpage: Action: Send Mail. In this way, can I embedded < the IncludeDoclink from Lotus Notes> in the body of the mail? Or I need to write a javascript for this action?
Thanks for your time!
UPDATE: following #Lothar suggestions, my Save & Send button has the following code lines:
if(frmDoc.isNewNote()){
frmDoc.save();
}
var thisdoc = frmDoc.getDocument();
var tempdoc = database.createDocument();
tempdoc.replaceItemValue("Form", "Memo");
tempdoc.replaceItemValue("SendTo", thisdoc.getItemValue("txt_names"));
tempdoc.replaceItemValue("Subject", "subject");
var tempbody:NotesRichtextItem = tempdoc.createRichTextItem("Body");
tempbody.appendText("This is my Mail, click on the doc link below to open the original doc:")
tempbody.addNewLine(2);
tempbody.appendDocLink(thisdoc);
tempdoc.send();
thisdoc.recycle();
tempbody.recycle();
tempdoc.recycle();
Where frmDoc is my doc datasource. I get an error like: NotesRichTextItem.appendDocLink(lotus.domino.local.Document) null - at the appendDoclink line. - the same error I noticed in the #Fredrik useful suggestion too.
I use the HTML email function that can be found in xSnippets when sending emails in xpages.
XSnippet SSJS HTML Mime emails
or
XSnippet email Bean
None of them as an function for attaching a doclink, but you could manually add an url to the document.
Another way is to create the email manually by creating a document is the database
adding a richtextfield called body and a subject and a sendto field.
And adding a doclink to the Body field.
var doc:NotesDocument = database.createDocument();
var My_DocLink_Doc:NotesDocument=database.getDocumentByUNID("UNID_of_Document")
doc.replaceItemValue("form", "Memo");
doc.replaceItemValue("sendTo", "the_emailadress");
doc.replaceItemValue("subject", "an email to you");
var RT:NotesRichTextItem=doc.createRichTextItem("Body")
RT.appendText("This is my Text")
RT.addNewLine()
RT.appendDocLink(My_DocLink_Doc)
doc.send();
There's really not much to add to Fredrik's answer, but I'm afraid you might be looking at the wrong pieces of his solution. I just tested it myself, and it's working just fine, so here's the result, step-by-step:
my xpage is bound to a Notes form named testMail using a document datasource called mailDoc. It is built like this:
Control#1 is a textarea with a multiple separator set to a comma, so that I can enter multiple mail addresses separated by commas. The textarea is bound to a Notes field named SendTo:
<xp:inputTextarea
value="#{mailDoc.SendTo}"
id="sendTo1"
multipleSeparator=",">
</xp:inputTextarea>
Control #2 is a simple EditBox control bound to a Notes field named Subject:
<xp:inputText
value="#{mailDoc.Subject}"
id="subject1">
</xp:inputText>
A button control labelled Save & Send first saves the current document if it is New (i.e. has never been saved before), then performs all the necessary steps to send a doclink for the currently opened doc (button's onclick event); in the following code I'm using these variables:
mailDoc = my datasource object;
thisdoc = the backend doc object that the datasource is bound to;
tempdoc = a temp backend doc object used to be sent via Notes mail:
if(mailDoc.isNewNote()){
mailDoc.save();
}
var thisdoc = mailDoc.getDocument();
var tempdoc = database.createDocument();
tempdoc.replaceItemValue("Form", "Memo");
tempdoc.replaceItemValue("SendTo", thisdoc.getItemValue("SendTo"));
tempdoc.replaceItemValue("Subject", thisdoc.getItemValue("Subject"));
var tempbody:NotesRichtextItem = tempdoc.createRichTextItem("Body");
tempbody.appendText("This is my Mail, click on the doc link below to open the original doc:")
tempbody.addNewLine(2);
tempbody.appendDocLink(thisdoc);
tempdoc.send();
thisdoc.recycle();
tempbody.recycle();
tempdoc.recycle();
Result: the button code sends a mail containing a Notes document link to all the recipients that I previously entered in the SendTo field.
If I set the testMail form's property to use the Xpage in Notes (Defaults >> On Open >> Display Xpage instead >> mailSendTest), then this also works for the XPinc version. And if the recipient then clicks on the doc link the originating document of course opens in XPinc mode as well.
Remark:
I need to save the originating doc at least once otherwise the appended doc link might not be usable for the recipients; could this have been the reason why Fredrik's answer didn't work for you?
Hope this helps. If this is working for you please accept Fredrik's answer.
Update:
Changed some variable names in my code example to clarify things
I simply use these two lines:
var url =
#Left(facesContext.getExternalContext().getRequest().getRequestURL(),"newDocument.xsp")+"newDocument.xsp?documentId="+document1.getDocument().getUniversalID()+"&action=openDocument";
rtitem.appendText(url);
where newDocument.xsp is the form xsp of the document, rtitem is the rich text field of the mail. That will add the whole link to your document.
am generating a new unique id whenever a document is been uploaded in sharepoint. Am fetching the new ListItem using Properties.ListItem(SPItemEventProperties) and updating the new unique id value.
It works fine for documents created using upload option. where as the 'Properties.ListItem is null' when using the "Open with Windows Explorer" option under Action Menu in sharepoint 2007. Could anyone please suggest me on this issue.
Thanks.
I think I've encountered this, and the solution was simply adding a null check - if the ListItem is null, don't continue the receiver.
The reason was that the receiver was then called again, and this time the ListItem was OK.
I had the same issue and fixed it by using the following work-around:
if (CurrentWeb.GetFile(properties.AfterUrl).Exists)
{
CurrentListItem = CurrentWeb.GetFile(properties.AfterUrl).Item;
}
else if (CurrentWeb.GetFolder(properties.AfterUrl).Exists)
{
CurrentListItem = CurrentWeb.GetFolder(properties.AfterUrl).Item;
}
See this link.
I built this function to find People Pickers by Field Title. Since the picker does not provide and TagName and Tile type of information and custom pages can have multiple people pickers, I used the NOBR tag which displays the title for each picker. This works flawlessly, but I think it can be sped up abit.
Please share your thoughts. Thanks you!!
function resetPickerInput(title){
var result="";
var tags=document.getElementsByTagName("NOBR");
var len=tags.length;
for(var i=0;i<len;i++){
if(tags[i].innerHTML.indexOf(title)>-1){
var div=tags[i].parentNode.parentNode.parentNode.getElementsByTagName("DIV");
var divLen=div.length;
for(var j=0;j<divLen;j++){
if(div[j].name=='upLevelDiv'){
result=div[j];
break;
}
}
}
}
return result;
}
Yes, you are doing it more complicated than you should.
This jQuery example looks very promising (Get Value of People Picker in Sharepoint):
var User = $("textarea[title='People Picker']").val().split("\\");
How do I get text from people picker textarea using javascript only
uses this: $(".ms-inputuserfield #content").each(function(){...
Another example: Hide People Picker control in SharePoint List Forms
Set a People Picker’s Value on a Form – Revisited with jQuery
$(this).find("div[Title='People Picker']").html(userName)
Since you didn't state your version: Retrieve Email Address from sharepoint people picker using javascript a solution for SP2007.