lotus notes: set numeric field of uidoc document - lotus-notes

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

Related

Graylog: how to search for custom properties

I would like to know how can I search for log messages with a custom properties containing a field named “Main Status” and value “Starting Process”…
how can i do that?
I'm making the assumption that the field is "Main_Status" or "MainStatus". Otherwise you may need to encode it "Main&20%Status", but I'd expect that to be problematic.
If that's acceptable then a query with the field and value would be something like Main_Status:Starting Process*.
You could also verify that the the field exists with something like Main_Status:Starting Process* AND _exists_:Main_Status.

Modifying an url in a MIME field

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

Dynamic field binding inside a repeat control

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.

Formula referencing parent doc works in computed field, not as default value

Following on from this question: Referencing parent field on document creation I'm using the formula for the default value for a name field.
IfError(#IfError(#GetDocField($ref;"ProductFamilyManager");
#GetDocField(ParentUNID;"ProductFamilyManager"));
"")
This works when it's a computed field, but not when i change it to be editable with a default value formula.
Any ideas how I can get the field populating with the default value?
The best way of doing this is to use #InheritedDocumentUniqueId. You need to enable inheritance to make that function available, but you don't actually have to inherit any of the parent values.
You should definitely not have to be using two different techniques and #IfError to get this done. And btw: did you know that #IfError is obsolete as of Domino 7?
It may not be supported but just to be sure, has the parent doc been saved before you create the response doc?
Assuming that's not the problem, the alternative is to use the "inherit field values from parent doc " option, which will pass a value from the parent doc to the response doc on creation. I may have the wording wrong but the option is on the form properties dialog in Designer.

How to change option set field to use another (existing) option set?

One field on Contact entity has 'option set' type. Now I want change field to use existing option set, but without re-creating field.
This option is currently disabled.
I don't think this can be done - once you've set a field up to use it's own option set, you can't change it to use a shared one instead, just as you can't change the field type or schema name after it's committed to the database.
If you've got a shared option set ready, it shouldn't be too big a deal to delete the field and re-create it with the shared option set. You would most likely lose the data which was in this field previously, though.
If this is an issue, consider exporting the data before making the change and then importing it back in, though I'm not sure of the exact details of how this would work.

Resources