Das Notes Forum

Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: TMC am 16.07.04 - 21:01:50

Titel: @IsNewDoc simulieren
Beitrag von: TMC am 16.07.04 - 21:01:50
Ich habe hier mitten in einem Script ein Backend-Dokument (docMail).

Anhand des Backend-Docs setze ich ein Frontend-Doc wie folgt:
Set uidocMail = uiws.EditDocument(True, docMail)

Danach verwerfe ich das (zuvor gespeicherte) Backend-Doc:
Call docMail.Remove(True) 'Backend löschen

Soweit so gut. Das ganze mache ich weil ich im Backend-Doc mit CreateRichTextItem arbeite - und da muss ich dann das Backend speichern bevor ich das ins Frontend bringe.

Einzigstes Problem:
Hidewhen-Formeln des Frontend-Docs reagieren nicht mehr auf @IsNewDoc. Klar, ich "erzeuge" ja das UIDoc via uiws.EditDocument.

Gibt es einen Trick, ein UIDoc als "NewDocument" zu deklarieren, damit @IsNewDoc ein "True" wiedergibt?

Aktuell gehts mir um diesen Forward-Button im Mailfile, der eben erscheint, wenn Doc nicht neu ist lt. @IsNewDoc:
(http://www.atnotes.de/attachments/forward01.gif)


*Edit*
Was natürlich gehen würde ist eine Anpassung der HideWhen-Formel. Aber das gilt es hier zu vermeiden.
Titel: Re:@IsNewDoc simulieren
Beitrag von: TMC am 05.09.04 - 18:40:45
Ich hol mal den Thread nach oben und werde auch mal im LDD-Forum fragen, vielleicht gibt's ja doch einen Trick  ;)


*Edit*
Hier noch das LDD-Posting:
LDD  4/5 Forum: NotesUIDocument.IsNewDoc = True (http://www-10.lotus.com/ldd/46dom.nsf/DateAllThreadedweb/6500b86b9e8b4ac785256f060061c4e7?OpenDocument)
Titel: Re:@IsNewDoc simulieren
Beitrag von: elajen am 06.09.04 - 09:16:41
Hallo,

schreib doch deine Hide-When-Formel um.
Ich habe ähnliche Probleme auch gehabt, und habe mir in der notes.ini ein Flag gesetzt.  Wurde das "neue" Dok dann geöffnet, habe ich beim schließen das Flag wieder entfernt.
Ist zwar nicht schön, funktioniert aber.

Gruß von Ekki
Titel: Re:@IsNewDoc simulieren
Beitrag von: TMC am 06.09.04 - 21:27:50
Hi Ekki,

genau das wollte ich aber vermeiden:
Was natürlich gehen würde ist eine Anpassung der HideWhen-Formel. Aber das gilt es hier zu vermeiden.
da es sich um das Mailfile handelt.
Titel: Re:@IsNewDoc simulieren
Beitrag von: TMC am 08.09.04 - 23:24:03
Hier übrigens der aktuelle Stand vom LDD-Forum, Andrew wollte wissen, welchen Code ich einsetze, also wo ich das brauche:

Zitat
Please find below my code-example, Andrew.

I've thrown out some not relevant parts, but this sub should work.
What does it do: If you have selected a document (in a view or it is an open document), it creates a new mail and adds a doc-link to the Body. You can use this sub either in a view button or in a form button.
I think, for helping you should take a look at my last 3 main code lines (commented by "Save backend, open frontend, remove backend").

Thanks,
Matthias


Public Sub NewLinkMemo(strSubject As String)

On Error Goto ERRORHANDLER

Dim uiws As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim docSource As NotesDocument
Dim dbMail As NotesDatabase
Dim docMail As NotesDocument
Dim uidocMail As NotesUIDocument
Dim docMailProfile As NotesDocument
Dim rtiMail As NotesRichTextItem

Set db = session.CurrentDatabase

'------------------------------------------------------------------------------
'Set doc depending on the source (view / form - button)
'------------------------------------------------------------------------------
If Not uiws.CurrentDocument Is Nothing Then
'agent was called via form-button
Set docSource = uiws.CurrentDocument.Document
Elseif Not session.DocumentContext Is Nothing Then
'agent was called via view-button
Set docSource = session.DocumentContext
End If

'------------------------------------------------------------------------------
'Check if Mail-DB exists
'------------------------------------------------------------------------------
Set dbMail = New NotesDatabase("","")
Call dbMail.OpenMail
If Not dbMail.IsOpen Then Error 1001, "Could not open user's mailfile"

'------------------------------------------------------------------------------
'Create email
'------------------------------------------------------------------------------
Set docMailProfile = dbMail.GetProfileDocument("CalendarProfile")
Set docMail = New NotesDocument(dbMail)
docMail.Form = "Memo"
docMail.Logo = docMailProfile.DefaultLogo(0) 'get default mail letterhead
docMail.Principal = docMailProfile.Owner(0)

'------------------------------------------------------------------------------
'Fill mail items
'------------------------------------------------------------------------------
docMail.Subject = strSubject
Set rtiMail = docMail.CreateRichTextItem("Body" )
Call rtiMail.AddNewLine(3)
Call rtiMail.AppendText("DocLink: " & " >")
Call rtiMail.AppendDocLink(docSource, "") 'Insert doc-link
Call rtiMail.AppendText("<")
Call rtiMail.AddNewLine(1)

'------------------------------------------------------------------------------
'Save backend, open frontend, remove backend
'------------------------------------------------------------------------------
Call docMail.Save(True,False) 'save backend
Set uidocMail = uiws.EditDocument(True, docMail) 'instantiate and open uidocMail
Call docMail.Remove(True) 'remove backend


EXITSCRIPT:
Exit Sub

ERRORHANDLER:
Select Case Err
Case 1001:
Msgbox Error$ & Chr(10) & "Operation was canceled.", 48, db.title
Case 4419
Msgbox "No document selected.", 48, db.title
Resume EXITSCRIPT
Case Else
Call ErrorMessage("NewLinkMemo")
Resume EXITSCRIPT
End Select
End Sub
Titel: Re:@IsNewDoc simulieren
Beitrag von: TMC am 09.09.04 - 23:13:22
Ich habe mittlerweile entdeckt, dass in ND6 die Hide-when-Formeln im Mailtemplate angepasst wurden.
Im LDD wurde mir auch bestätigt, dass es so keine Möglichkeit gibt:

Zitat
Posted by Stan Rogers on 8.Sep.04 at 18:28 using a Web browser

There's nothing you can do about @IsNewDoc; that property is read-only, and is only ever true when a document is being composed (i.e., a blank form is open to the UI). In this case, you are editing an existing document, even though that document has never been saved.

You can still tell whether or not the document has been saved using NotesDocument.IsNewNote, but there's no equivalent in Formula Language (no @IsNewNote), since Formula Language does not differentiate between UI and back-end documents. Your problem is not that the @IsNewDoc = @False, it's that you're relying on a hide-when formula that came in the box. You'll need to either modify the hide-when ( PostedDate="" makes a good formula ) or live with the Forward button being present.

Meine Antwort:
Zitat
Thanks, Stan, for your response.

This confirms my investigations and experiences so far.
By the way, I found out that IBM has improved the ND6-mailtemplate hide-whens: when I use use my Script in an ND6-environment, the Forward-button does not appear.
So, it is only a matter of time :-)

Thanks,
Matthias

Ergo: (http://www.atnotes.de/YaBBImages/solve.gif)  ;)