header
Menu Principale
Home
Novità
Novità ICT
Blog
Links
In un'altra vita...
... in questa vita
Sto studiando...
Contattami
Ricerca
Il libro degli ospiti
News Feeds
Downloads
La Licenza di Joomla!
Tutti i link
Fastnet: la mia azienda
Sponsored Links

Album più recente

EMBA-ICT Finance: Cena 10 luglio 2008 EMBA-ICT Finance: Cena 10 luglio 2008
Rss Ict
Punto Informatico
Il quotidiano di Internet dal 1996
Linux Today
Linux Today News Service
 
Home arrow Novità ICT arrow IBM Lotus arrow Aggiornare dinamicamente campi rich-text con LotusScript
header
Aggiornare dinamicamente campi rich-text con LotusScript PDF Stampa E-mail
Valutazione utente: / 0
ScarsoOttimo 
Scritto da Filippo Del Prete   
martedì 19 agosto 2008

Fastnet Spa Di seguito la traduzione di un articolo che illustra come gestire tramite LotusScript gli allegati in un campo rich-text sul documento Lotus Notes aperto sul front-end.

 Lotus

Aggiornare dinamicamente campi rich-text con LotusScript

Titolo originale: "Dynamically update Lotus Notes rich-text fields using LotusScript"


Autore: Amith Narera
11.20.2007

Una modifica effettuata su un documento Lotus Notes nel back-end viene solitamente riprodotta nel documento di front-end, ma u'eccezione a questo comportamento sono i campi di tipo rich-text. Per le modifiche ai campi rich-text, si deve chiudere il doumento Lotus Notes di front-end e aprirlo di nuovo usando il metodo NotesUIWorkspace.EditDocument. Comunque, questo fa "scatenare" tutti gli eventi associati alla form Lotus Notes. Questo tip aggira questo problema consentendo di aggiornare dinamicamente i campi rich-text del front-end senza chiudere e riaprire la form Lotus Notes principale.

A scopo esemplificativo, aggiungo l'attuale username Lotus Notes, l'ora di sistema e gli allegati (selezionati dall'utente Lotus Notes) al campo rich-text. Il seguente codice LotusScript consente anche di appendere item rich-text da un altro documento Lotus Notes (codice commentato).

Quello che segue è uno schema di come il codice LotusScript lavora:

  • Crea un documento Lotus Notes "di appoggio" nel back end usando il metodo db.CreateDocument.
  • Aggiunge un campo rich-text al documento.
  • Esegue tutte le azioni necessarie su questo campo rich-text .
  • Apre il documento Lotus Notes nel front-end coun una form "di appoggio" che contine solamente un campo rich-text (con lo stesso nome di quello creato nel secondo passaggio visto prima).
  • posiziona il cursore in questo campo rich-text, seleziona tutto il testo, e copia tutto negli appunti.
  • Chiude la form Lotus Notes "di appoggio".
  • Va sul campo rich-text di destinazine sulla form Lotus Notes principale.
  • Incolla tutto dagli appunti.
  • Missione eseguita.

Questi sono gli step necessari per ottenere il risultato desiderato:

  1. Create a new form. Name it "Dummy Form."
  2. Place a rich-text field, named "DummyRT" on it.
  3. Open your main Lotus Notes form where you'd like these updates to happen.
  4. Create a new Action button, and name it "Update RT Field." You may use the LotusScript code anywhere. For the sake of simplicity I am using it in a button.
  5. Select LotusScript as the coding language and paste the code given below into it.
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession

'COMMENT #######> UiDoc represents the currently open Fron End document, where the rich text field exists.
Dim uidoc As NotesUIDocument

'COMMENT #######> Dummy UIDoc ---needed by the code
Dim DummyUIDoc As NotesUIDocument
Dim db As NotesDatabase

'COMMENT #######> Back End version of DummyUIDoc
Dim DummyDoc As NotesDocument

'COMMENT #######> RT Item in DummyDoc ---From where you would be pulling the changes
Dim DummyRT As NotesRichTextItem
Dim FilePath As Variant

Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument

Set DummyDoc = db.CreateDocument

'COMMENT #######> Set Fields for Dummy Document
DummyDoc.Form = "Dummy Form" ' NOTE: It shud be dummy form, not your main form.
DummyDoc.SaveOptions = "0"

'COMMENT #######> Get the File path for the file to be attached
FilePath = workspace.OpenFileDialog(True, "Select Files")

'COMMENT #######> Insert RT Field
Set DummyRT = New NotesRichTextItem(DummyDoc,"DummyRT")

'COMMENT #######> Update the Field- as per your requirements
Call DummyRT.AppendText(session.CommonUserName & " - ")
Call DummyRT.AppendText(Cstr(Now))
Call DummyRT.AddNewline(1)

'COMMENT #######>Embed Selected Files, if Any
If Not Isempty(FilePath) Then
Forall CurrentFilepath In FilePath
Call DummyRT.EmbedObject(1454,"", CurrentFilePath)
End Forall
End If
'COMMENT #######>You may also append an RT Item from any other document. eg.
%REM
Dim RTItemB As NotesRichTextItem
Set RTItemB = DocB.GetFirstItem("RTItemName")
Call DummyRT.AppendRTItem(RTItemB)
%END REM

'COMMENT #######> Call this to commit all the RT Item Changes to the Document
Call DummyRT.Update

'Here is the Trick
'*******************************************************************************************
Set DummyUIDoc = workspace.EditDocument(True,DummyDoc)
Call DummyUIDoc.GotoField("DummyRT")
Call DummyUIDoc.SelectAll
Call DummyUIDoc.Copy
Call DummyUIDoc.Close(True)
'COMMENT #######> Goto Main doc Rich Text Field (desitnation field)
Call uidoc.GotoField("RTF")
Call uidoc.Paste

'*******************************************************************************************
Messagebox "Process Completed Successfully.", 64, "Complete"
End Sub

Now -- with a click of this action button -- you can update the front end of your rich-text item in real-time without having to close and re-open the main Lotus Notes document. You can also apply the same logic to move contents of one rich-text item to the other rich-text item on the same form in real time -- without having to re-open the front end document. If you'd like to do that, this code will help you:

Call UIDoc.GotoField("FirstRT")
Call UIDoc.SelectAll
Call UIDoc.Copy
Call uidoc.GotoField("SecondRT")
Call uidoc.Paste


Riporta quest'articolo sul tuo sito! | Visualizzazioni: 261

Lascia il primo commento!
Commenti RSS

Scrivi Commento
  • Si prega di inserire commenti riguardanti l'articolo.
  • Commenti ritenuti offensivi verranno eliminati.
  • E' severamente vietato qualsiasi tipo di spam. Cose del genere verranno cancellate.
  • Assicurati di aggiornare(refresh) la pagina per visualizzare un nuovo codice.
  • Ovviamente questo accade se hai inserito il codice errato.
Nome:
E-mail
Sito web
Titolo:
Commento:

Codice:* Code
Desidero essere contattato quando vengono pubblicati altri commenti

Powered by AkoComment Tweaked Special Edition v.1.4.6
AkoComment © Copyright 2004 by Arthur Konze - www.mamboportal.com
All right reserved

 
< Prec.   Pros. >

 
 
5 miei libri a caso
Tags Cloud

sistema database

Powered by RafCloud 2.0.2
Che tempo fa
Ancona/Falconara, Italy
temperatura: 12°C
Freddo del vento: 12°C
Umidità: 82%
Velocità del Vento: 16 km/h
direzione: 200°
Barometro: 1000.0 mb
SSW
mostra più particolari
fornito da: 
View Filippo Maria Del Prete's profile on LinkedIn
Ultimissime
Una foto...
P0001959 P0001959
Re-Designed By Me original design By MeMoodleThemes