I have a Notes document with a field BodyMime where the Store content as HMTL/MIME is set.
In that field, I have some notes URL : Notes://ServerNameA/DB.
I need to replace all the occurrences in the MIME field to put Notes://ServerNameB/DB.
I tried TeamStudio Configurator , he is able to do the change but I am losing all CSS and Format.
Anybody who have an idea what I can do ?
Some Example ?
Thanks a lot
You can try Genii Software MidasLSX. It's a commercial product.
If you don't want to spend any money, you can use NotesDXLExporter and NotesDXLImporter classes to export, replace, and import back the documents.
You can write a LotusScript agent to process each document, use
Session.ConvertMIME = False
before you get the NotesDocument. This prevents the loss of formatting as there is no conversion to RichText.
You can then
Set mime = NotesDocument.GetMIMEEntity
then iterate through the Mime.ChildEntities
Set child = mime.GetFirstChildEntity
While Not(child Is Nothing)
then use DecodeContent or create a NotesSession.CreateStream and use mime.GetContentAsText(stream)
eg
Call child.DecodeContent
You can then search and replace in the child.ContentAsText and re-encode the mime-entity.
Call child.EncodeContent(ENC_QUOTED_PRINTABLE) ' (1762) or use any other encoding scheme.
Set child = child.GetNextSibling
Wend ' iterate through all mime-entities
finally remember to save your NotesDocument
Related
i have a problem to set numeric field in lotus notes script from uidoc, i have already tried:
call uidoc.fieldsettext("field",value)
but if "field" is numeric field and the value is a number(or a variable containing a number) i can't use fieldsettext method because field is initialized as text and i want numeric.
There is a method like fieldsetnumber or also like it ?
I don't want switch the document from uidoc to doc.
thank's
uidoc.FieldSetText() is the best option and when you save the value will be converted to the appropriate data type, at least according to the documentation.
If using FieldSetText, you have to be careful to format the value in a way that's consistent with the user's preferences and/or the settings of the field (e.g. whether the decimal separator is "," or "."). To avoid this source of error, it's better to use the NotesDocument object for this sort of thing. You need a better reason than "I don't want to," to not do this.
You could use the NotesDocument for this one operation and the NotesUIDocument for everything else, e.g. write:
uidoc.Document.ReplaceItemValue "fieldname", numbervalue
Unless you've deliberately set the option to not reload the UI automatically, this will do what you want. If you have set that option you'll need a second call to do that update.
It's worth remembering that you don't really 'switch' between the NotesUIDocument and NotesDocument - it's the same entity, just with a different set of classes.
The action you want to perform is never going to be 100% reliable with end users being able to change the format of the Date/Time field to suit themselves. Much better interacting with the backend and reloading the UIDoc.
What is the reason you don't want to use NotesDocument?
Nick
I have a strange thing, I'm using dynamic field binding in a custom control.
The field binding is created like this.
XPage (Datasource "document" is placed here)
Custom Control (String passed in)
(to get errors if there are any)
Repeat (CompositeData is passed to a bean that returns the strings for Rows,columns)
Repeat (repeat 1 variable used for Columns)
Custom Control (fieldname is passed in)
field binding is done like this
#{document[compositeData.fieldName]}
The problem is that when I save the XPage I get an error in the messages control
Document has been saved by another user - Save created a new document as a response to that modified document.
And all fields are cleared.
Any ideas how to debug this or is there something I'm missing?
The "Document has been saved by another user" error is only tip of the iceberg - there are some really strange problems with reapeats that repeats fields that are bound and repeatControls property is set to false. The decoding part of xpages lifecycle cannot handle it properly - the controls will be losing data. You should use repeatControls set to true as Martin suggests.
"Repeat control variable doesn't exists" is probably caused by the property that removes repeats set to true. You can solve this by either changing it to false or by adding additional data context that will keep repeated value.
And finally for this to have add/remove functionality You can use Dynamic Content Control and show(null) hack to rebuild the repeat content.
To manage this complexity better I would advise You to stop using document data source and start creating some managed beans.
If You will follow my suggestions I guarantee that You will get the functionality You are looking for as I have few apps that works great and have this kind of complex data editors in them.
I don't know if it'll help you, but I pass both the document datasource and the field name as parameters to a DynamicField control, and use it like this:
compositeData.dataSource[compositeData.fieldName]
The type of the datasource is com.ibm.xsp.model.DataSource, it's listed as dataInterface under Data Sources.
Do you have repeatControls="true" set for the repeat control?
It sounds like you've got the datasource defined multiple times on the XPage (plus custom controls). Either that or the save button has save="true" but the code saves the document back-end, or code in multiple places saves the same document. I've used the same method of passing the datasource down to the custom control, but that may just be because that was what I saw on a blog.
On SalesForce ,
I've got a word document as an attachment of a custom object, i can get it as blob by selecting the body of the attachment with a SOQL query :
Attachment att = [ SELECT Body FROM Attachment WHERE PARENTID = '**' and ContentType='application/msword'] ;
Blob b = att.body ;
I tried to use the b.toString() function to have the content, but it didn't work.So is there any other way to convert the blob into a string that represent the text written in my word document.
thanks
Document bodies are saved as Blobs and are base64Encoded. Please use the EncodingUtil class and bas64Encode/base64Decode methods to achieve the desired results.
Documentation: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_encodingUtil.htm
What exactly are you trying to achieve with this?
If you are trying to display the doc. content and let the user edit/save it. This is not possible unless ActiveX controls are used which is another different level.
Please post the code if any coding help is required!
The b.toString() method should return a string of the blob. But keep in mind that it isn't translating the proprietary format of the word document into plain text. It's still going to be a string with some ugliness because it represents the word document format and not the text you would see when viewing from word.
I am having some documents. If I try to open the document then it shows error like "field is too large 32k or view's column & selection formulas are too large"
Whenever I try to delete the document, I am getting the same error. I am not able to delete.
Okay we can try to get the document via backend, But there, I can not get the document handle.
Whatever I try to search then the document collection count is 0.
Important:- I am using Notes 6.5.2.
Thanks in Advance,
You may create new replica of the database, currupted documents won't be copied. Also you may try to use ScanEZ tool from Ytria.
"Okay we can try to get the document via backend, But there, I can not get the document handle."
Could you post the code you are using?
I don't see why the following code would not work:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim deleteDoc List as NotesDocument
Set db = session.Currentdatabase
'*** Get collection of selected documents
Set col = db.UnprocessedDocuments
'*** Loop through selected documents
Set doc = col.GetFirstDocument
Do Until doc Is Nothing
'*** Add document to list to delete later
Set deleteDoc(doc.UniversalID) = doc
Set doc = col.GetNextDocument(doc)
Loop
'*** Delete all documents in list from database
ForAll d in deleteDoc
Call d.Remove(True)
End ForAll
Perhaps you may want to change the field that causing you headache to rich text since the limit for rich text field is slightly bigger that normal text field. The limit for rich text filed is limited only by available disk space up to 1GB
Have you tried to simply delete the problem field on a corrupt document, and then delete the document? You can try to do the following:
1- create an agent set to run on selected documents with the following formula:
FIELD corruptfield := #DeleteField;
2 - select a problem document in a view and run the agent
3 - if that does not error out, then try to manually delete the document from the view.
Here is what worked for me :
1/ Get the Note ID of the doc with DocViewer
There may be many other ways to get the NoteID, but it just showed up when I tried to send the doc through DocViewer, the well known free tool
https://www.openntf.org/main.nsf/project.xsp?r=project/Document%20Viewer/summary
2/ Remove the doc with Notes C API
I followed the advice of pstr, and quickly found out this script
http://www.nsftools.com/tips/ApiStublessDelete.lss
Just aim it at the good database, with the Note ID, and it does the trick !!
I tried to change the script in order to not remove the deletion stub (I wished the removal would replicate over my cluster and local replica). But you fall back on the 32k error ! So you have to apply the deletion over every replica (or recreate the replicas of course).
How do you create a lookup column to a Document Library that uses the 'Name' of the document as the lookup value?
I found a blog post that recommends adding another custom field like "FileName" and then using a item reciever to populate the custom field with the value from the Name field but that seems cheesy.
Link to the blog in case people are interested:
http://blogs.msdn.com/pranab/archive/2008/01/08/sharepoint-2007-moss-wss-issue-with-lookup-column-to-doc-lib-name-field.aspx
I've got a bunch of custom document content types that I dont want to clutter with a work around that should really work anyway.
I created a one step workflow to set the title from the name, fired on modify and created. Seems to work and took seconds to create.
One way you can do this (although not the easiest way) is by creating a custom field type that extends the SPFieldLookup class. SharePoint's field editor for Lookup fields purposefully hides any columns types that aren't supported by Lookup fields, but you can create a field editor for your custom field type that shows them.
However, I have created a Lookup column that points to a Name column in a Document Library before, and it probably doesn't work like you'd expect. While the value stored in the lookup column is valid, it doesn't show up right in List view or on the View Properties form.
The solution you posted may actually be the best way to handle this. Lookup fields require some kludges if you want to handle more complex scenarios, but that's because they're not meant to provide the same functionality as a foreign key relationship in a database.
Coding in any form always scares me. So Here's what I did: I simply renamed the Stupid "Title" Field to something else, say "Keywords", since you cant do anything with that field: cant even make it mandatory.
Then I created another Single line field called "Title" and used this field for the Lookups
Well there is a simple solution to that and in might work in some case.
In the nutshell if you make the Title field Mandatory, this will force the user to enter a title. In that manner we can use title field as a lookup field.
Now How to do that?
One you are done create a document library go to the library setting. Select Advance Setting and Select Yes for the option "Allow management of content types?".
Then go back to the Library setting and Under content types select the "Document" Content type. THen Select Title Column and then Select "Required (Must contain information)" and say OK.
Now try uploading a document to this document library. You will see Title field in the form.
Hope this helps
Cheers
Vaqar
You have to add the field as XML with the ShowField as 'FileLeafRef'
var XmlFieldDefinition = "<Field DisplayName='myLookupColumn' Type='LookupMulti' StaticName='myLookupColumn' Name='myLookupColumn' Required='FALSE' List='THE LOOKUP ID HERE' WebId='THE WEB ID HERE' UnlimitedLengthInDocumentLibrary='TRUE' Mult='TRUE' Sortable='FALSE' ShowField='FileLeafRef' />"
Field fld = fieldCollection.AddFieldAsXml(XmlFieldDefinition, true, AddFieldOptions.DefaultValue);
ClientContext.Load(fld);
ClientContext.ExecuteQuery();