In the end of the document, I want to show a checkbox with a prepopulated text, something like:
[ ] By checking, I've read the whole document and agree to sign.
Use a 'text' (old documentation, new documentation, expand the text menu at the bottom) to display your text.
In C#, it would look like this :
Text myText = new Text
{
Value = "By checking, I\'ve read the whole document and agree to sign.",
DocumentId = "123",
PageNumber = "1"
};
Related
I'd like to insert the text string into the existing rich text field data at the first position for all of documents in a DB.
NotesRichTextNavigator.FindFirstElement method - This method needs to specify the element type to search but I simply insert the text at the first position of the rich text data.
This might be very basic question, but I could not find the way and waste a few hours... Please help me!
You can do this using a workaround. Instead of working with FindFirstElement, you create a dummy richtextitem, containing the text that you need to prepend to your original item,
add the original item to the dummy item, delete the original item and recreate it.
Then add the dummy item and delete the dummy.
This sounds complex, but it is not that hard actually. Here's a small example in LotusScript on how to do this on a document:
'Get your richtext field
Set rtf = doc.getfirstItem("myRTF")
'create the dummy
Set rtDummy = doc.Createrichtextitem("rtfDummy")
'set the text that you want to insert in your richtext field
Call rtDummy.appendText("Inserting a line of text at the top")
'Add a line to make sure the inserted text is on a separate paragraph
Call rtDummy.Addnewline(1, true)
'Add the content of the original richtext item
Call rtDummy.Appendrtitem(rtf)
'Remove the original item and recreate it
Call rtf.Remove()
Set rtf = doc.Createrichtextitem("myRTF")
'Append the dummy item (including the added text)
Call rtf.Appendrtitem(rtDummy)
'Remove the dummy item
Call rtDummy.Remove()
'Save the document
Call doc.Save(True, True)
I'm trying to build an applescript to sort tags in the Genre field of a music file in iTunes.
I'm using a semi-colon separated list for the Genre field, like this: Rock; Art Rock; Female Vocalists
The string I want to sort is named genreList in my script:
{"Art Rock", "Female Vocalists", "Rock"}
My preferred tag order is listed as sortList:
{"Rock", "Dance", "Art Rock", "New Wave", "Female Vocalists", "Male Vocalists"}
I want the items in genreList to sort according to sortList, like this:
{"Rock", "Art Rock", "Female Vocalists"}
How do I sort the first list using the second list? I've searched here and on Google, but as I am a scripting novice I'm not even sure I'm searching for the right terms.
Try this, select one or multiple tracks in iTunes and run the script.
If the separator is supposed to be semicolon + space, please change the second property line.
If the genre property does not contain the separator, nothing will be changed.
If a genre does not match the items in the sorted list it will be appended at the end.
property sortedGenreList : {"Rock", "Dance", "Art Rock", "New Wave", "Female Vocalists", "Male Vocalists"}
property separator : ";"
tell application "iTunes" to set selectedItems to (get selection)
if selectedItems is {} then
display dialog "Nothing selected" buttons {"Cancel"} default button 1
end if
set {TID, text item delimiters} to {text item delimiters, separator}
repeat with aTrack in selectedItems
set orderedGenreList to {}
set nonOrderableGenres to {}
tell application "iTunes" to set trackGenreList to text items of (get genre of aTrack)
if (count trackGenreList) > 1 then
repeat with aGenre in trackGenreList
if sortedGenreList does not contain aGenre then set end of nonOrderableGenres to contents of aGenre
end repeat
repeat with aGenre in sortedGenreList
if trackGenreList contains aGenre then
set end of orderedGenreList to contents of aGenre
end if
end repeat
set orderedGenres to (orderedGenreList & nonOrderableGenres) as text
tell application "iTunes" to set genre of aTrack to orderedGenres
end if
end repeat
set text item delimiters to TID
If you want to use a text file with a genre per line replace the first property line with
set sortedGenreList to paragraphs of (read (choose file))
I have a Rich Text field in Lotus Notes. But I am not sure how to clear the contents of the field.
I have tried the following:
ReplaceItemValue:
doc.ReplaceItemValue("RichTextField", "")
ReplaceItemValue does not work for a Rich Text field.
vRTItem.Values = "":
Set vRTItem = doc.GetFirstItem( "RichTextField" )
vRTItem.Values = ""
This didn't help.
RemoveItem:
Set vRTItem = doc.GetFirstItem( "RichTextField" )
Call doc.RemoveItem("RichTextField")
Set vRTItem = doc.CreateRichTextItem( "RichTextField" )
But none of them worked.
It would be helpful to see the all the code you've written and where this code is triggered (document event, button, agent, etc)
What you have should work but you need to save the document after you call those methods:
doc.Save(false, false)
The "First" in the doc.GetFirstItem() method is a hint that there may be more than one.
I'd go with the doc.RemoveItem("theNameOfTheItem") : be sure to save the doc afterwards, before doing anything else with the doc.
At first, there's a rich text field in the form that has a text inputted already (for this scenario - "hello world"). I have placed the cursor just after the letter "o" from "hello". I have a button that will open up a dialog box with one text field and I was wondering how would you be able to insert the text from that field from the dialog box at the current position of the cursor in the rich text field.
So far the code I have is:
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.currentdatabase
Dim docFill As New notesdocument(db)
Call workspace.DialogBox _
( "Test", True, True, False, False, _
False, False, "Test Insert text at current position in rich text field", docFill, True, False, True )
Dim string1 As String
string1 = docFill.sampleText1(0)
Dim rts As NotesRichTextStyle
Set rts = s.CreateRichTextStyle
End Subs
End Sub
Let's say I entered "stackoverflow" in sampleText1 text field. After clicking ok then it will be inserted at the position of the cursor in the rich text field. So the result will be "hellostackoverflow world".
Also just an additional question. Let's say I also wanted the text to be in color red or a different font so I would be using notesrichtextstyle class etc to design it. How would you be able to insert the rich text at the position of the cursor in the rich text fiel if that would be the case?
You can insert text at current cursor position with the help of the clipboard. Just let the user insert text in a dialog box, select the text after clicking "OK", copy it and then paste it at the current cursor position in RichText field back in your form.
To accomplish that, create an action "Insert text" in your form's action bar with the LotusScript code
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
If workspace.DialogBox _
("Dlg", True, True, False, True, _
True, False, "Test insert text", doc, True, False, True ) Then
uidoc.Paste
End If
End Sub
Actions in action bars have the advantage that they don't change the cursor position in document on click event. So, the cursor still remains on current position e.g in RichText field clicking on an action button.
Then, create a form "Dlg" for DialogBox with a Text or RichText field "Text". Add the following formula code to form's Postrecalc event (it's executed on "OK" button click):
#Command([EditGotoField]; "Text");
#Command([EditSelectAll]);
#Command([EditCopy])
You have a lot of options with the copy-paste-approach to put content into clipboard:
Create a text in backend and put it direct into clipboard
Create a RichText item in a temp document with all content and style options you can think of, open the document in UI, copy the RichText item content to clipboard and close document without saving
Let users create their text snippet in documents. Let them choose one of it clicking on "Insert text" button - just open the selected document, copy the content to clipboard and close it.
The first problem is that when you click the action button, you will lose focus of the rich text field, and therefor there is no way to know where the cursor was.
I would also suggest that you don't use the extended notation like this:
string1 = docFill.sampleText1(0)
Use the GetItemValue method of the NotesDocument class instead (for several reasons, including performance and future-proofing your code.
If you just want to have the user enter some text, why not use the InputBox function?
Finally, there is not an easy way to insert text in the middle of a rich text. It is much easier to perform a replace of a specific text string in a rich text field. I once created a Lotusscript class to perform mailmerge (create letters based on a template and a form letter with field names and commands), you can find it here: http://blog.texasswede.com/code-mail-mergeform-letters-in-lotuscript/
Perhaps that can help you some. But it has to be done in the backend, you can't do much rich text work in the frontend, unless you use Midas LSX frpn Ben Langhinrichs (http://www.geniisoft.com). I think he got some UI functionality.
But your biggest issue will be the first problem, how to trigger the code without losing focus of the rich text field. I don't see a good solution there. You may want to rethink your design/approach.
If you use a button in the Action Bar then the focus will remain with the rich text field. You can then use uidoc.InsertText("") to insert the text at the current position of the cursor.
You could use...
call uidoc.InsertText( docFill.sampleText1(0) )
I try to print PDF with HyperLink, without succes
I have a lock field "etat" with data
Data are formatted like:
Code TAB Nom TAB Adress TAB Ville
56 Eric rue caboteur ST NAZAIRE
87 Franc rue Midin ST brevin
etc
the textStyle of item 3 "Adress" set to "Link and linktext set to ""http://maps.google.fr/maps?f=q&hl=fr&q=theadresse""
When i click on hyperlink item in field "etat" that work fine
Now i would like have the same result after printing this field in PDF
I use this code for printing
on mouseUp
local theResult,thepDF
ask file "" with type "PDF file|pdf|PDF "
if it = "" then
exit mouseUp
end if
put it into thePDF
put the htmltext of fld "etat" into theResult
--set the fileType to "revoPDF "
open printing to pdf thePDF
revPrintField the name of field "etat"
--revPrintText theResult,"<%pageNumber%> of <%numPages%>","<%pageNumber%> of <%numPages%>",the long id of field "etat" of stack "CDH"
close printing
end mouseUp
I have a nice PDF with clicked words, but the click don't launch google maps
The dictionary say for command "print link"
"When printing fields, any text that has its linkText property set together with the link textStyle is treated as if a print link command had been executed with the contents of the property as link, and the formattedRect of the text as rectangle."
But no work.... I have a big headache
Thank for yours help to achieve this
Eric
I am trying to understand your problem and reading through your code, I think maybe the link text…
"http://maps.google.fr/maps?f=q&hl=fr&q=theadresse"
should be…
"http://maps.google.fr/maps?f=q&hl=fr&q=" & theadresse
This is assuming theadresse is a variable containing a valid address to search in Google.