Domino 9 und frühere Versionen > ND6: Entwicklung

Formel in Skript umwandeln

<< < (4/5) > >>

judicious:
@MailSend( antragsteller ; copyTo ; blindCopyTo ; "Your E-Mail address request" ; "Dear " +v_name ; "Für weitere Informationen klicken Sie bitte auf die Verknüpfung: "; [IncludeDoclink] : [Sign] );

Das klappt aber? Also da kommt kein Error und der Link wird auch geschickt.

ICh habe hier noch etwas anderes, dort kommt aber immer der Fehler ich rufe eine unbekannte Funktion auf. Bei den Scripts ist dieses File: lib20SendMail

--- Code: ---Sub SendMail(sSendto As String, sSubject As String, sMailtext As String, _
docRequestdoc As NotesDocument, sOriginator As String)

Dim ses As New NotesSession
Dim ndbCurrentDB As NotesDatabase
Dim docMailDocument As NotesDocument
Dim rtBody As NotesRichTextItem
Dim nSendto As NotesName

Set ndbCurrentDB = ses.CurrentDatabase
Set docMailDocument = New NotesDocument( ndbCurrentDB )
Set rtBody = docMailDocument.CreateRichTextItem( "Body" )
Set nSendto = ses.CreateName(sSendto)

'Set Fields for the Mail
docMailDocument.SendTo = nSendto.Abbreviated
docMailDocument.Subject = sSubject

'Set Body Field for the Mail
Call rtBody.AppendText( "Guten Tag" )
Call rtBody.AddNewLine( 2 )

Call rtBody.AppendText( sMailtext )
Call rtBody.AddNewLine( 1)
Call rtBody.AppendDocLink( docRequestdoc, "Zum Antrag gehen")
Call rtBody.AppendText( " - Link zum Dokument" )
Call rtBody.AddNewLine( 2)

Call rtBody.AppendText( "Mit freundlichen Grüssen" )
Call rtBody.AddNewLine( 2 )
Call rtBody.AppendText(sOriginator )

'Send the Mail
Call docMailDocument.Send( False )
End Sub
--- Ende Code ---

Dann habe ich einen Button der das macht:

--- Code: ---Sub Click(Source As Button)


Dim vReaders As Variant 'The Readers of the Document
Dim sSendto As String 'The  Sendto part of the Mail
Dim sSubject As String 'The Subject of the Mail
Dim sMailtext As String 'The Text of the Mail
Dim sMailSender As String 'The Originator of the Mail

Dim uiws As New NotesUIWorkspace
Dim uidocCurrentDocument As NotesUIDocument

Dim ses As New NotesSession
Dim docCurrentDocument As NotesDocument
Dim nmDecisionMaker As NotesName
Dim itemReaders As NotesItem

Set uidocCurrentDocument = uiws.CurrentDocument
Set docCurrentDocument = uidocCurrentDocument.Document
Set nmDecisionMaker = New NotesName(ses.UserName )
Set itemReaders = docCurrentDocument .getfirstitem("rReaders")

'Goes shure that the Document is in the Edit mode
uidocCurrentDocument.EditMode = True

'Adds the Role of the Time Administrators to the Readers field
itemReaders.AppendToTextList("[TimeAdmin]")

'Is because the item is updated. it isn't possible to update the other fields without saving
Call uidocCurrentDocument.save

'Setting the Fields
Call uidocCurrentDocument.FieldSetText("nmDecisionOf",Cstr(nmDecisionMaker.Abbreviated))
Call uidocCurrentDocument.FieldSetText("dtDecisiondate", Cstr(Now))
Call uidocCurrentDocument.FieldSetText("tStatus", "Genehmigt")
Call uidocCurrentdocument.fieldsettext("aAuthors","[DBAdmin] ; [TimeAdmin]")

Call uidocCurrentDocument.save

'Sets the Variables to send the mail

sSendto = Cstr(uidocCurrentDocument.FieldGetText("nmOriginator"))
sSubject = "Ihr Antrag wurde bestätigt"
sMailtext  = "Ihr Antrag wurde genehmigt. Anbei noch den Link zu ihrem Antrag."
sMailSender  = nmDecisionMaker.Common


Call SendMail(sSendto , sSubject , sMailtext, docCurrentDocument, sMailsender)

'Goes shure that the user isn't asket if he wants to save and saves the Document
Call uidocCurrentDocument.FieldSetText("SaveOptions", "0")
Call uidocCurrentDocument.Close

End Sub
--- Ende Code ---

Dabei kommt der Fehler beim Button:
Not a sub or function name: SENDMAIL

umi:
Benutzt Du den diese Lib auch ?
use "lib20sendmail" im Abschnitt options deines Buttons oder des Forms?

judicious:
Ich habe es doch jetzt kommt wieder der Fehler ich hätte keine Default View. Wie kann ich eine Default View festlegen? WO und WIE? Sorry für die blöden Fragen.

Juhu ich habe es hinbekommen. Man muss die View offen haben und dann kann man das in den Properties ändern. Ich habe es immer mit einem Rechtsklick versucht. Das ging natürlich nicht.

Untitled:
View Eigenschaften -> "i"-Reiter -> "Default when database ist first opened"

p.s. es gibt keine blöden Fragen.

Grüsse

judicious:
So jetzt wird es doch nochmal mysteriös. Ich habe einen Button der diese Formel hat:


--- Code: ---safe:= @Prompt([YesNo];"Safety First";"Are you sure you want to decline this request?");

@If(safe=1;
@Do(
@Command([EditDocument]);
@Do(@SetField("zeigestatus"; "declined"));
@Do(@SetField("Author"; ""));
@Command([ViewRefreshFields]);
@Do(@Command([FileSave]))
);
""
)
--- Ende Code ---

Funktioniert wunderbar. Im querysave habe ich dann den Mailcode


--- Code: ---If Source.FieldGetText("zeigestatus") = "declined" Then
If Source.FieldGetText("ablehnungsgrund") = "" Then
source.GotoField("ablehnungsgrund")
Messagebox "Decline reason field is empty",  0 + 48, "Failure"
Continue = False
Exit Sub
End If

Dim vReaders As Variant 'The Readers of the Document
Dim sSendto As String 'The  Sendto part of the Mail
Dim sSubject As String 'The Subject of the Mail
Dim sMailtext As String 'The Text of the Mail
Dim sMailSender As String 'The Originator of the Mail

Dim uiws As New NotesUIWorkspace
Dim uidocCurrentDocument As NotesUIDocument

Dim ses As New NotesSession
Dim docCurrentDocument As NotesDocument
Dim nmDecisionMaker As NotesName
Dim itemReaders As NotesItem

Set uidocCurrentDocument = uiws.CurrentDocument
Set docCurrentDocument = uidocCurrentDocument.Document

sSendto = Cstr(uidocCurrentDocument.FieldGetText("v_username"))
sSubject = "Ihr Antrag wurde bestätigt"
sMailtext  = "Ihr Antrag wurde genehmigt. Anbei noch den Link zu ihrem Antrag."
sMailSender  = Cstr(uidocCurrentDocument.FieldGetText("v_username"))

Call SendMail(sSendto , sSubject , sMailtext, docCurrentDocument, sMailsender)

Call uidocCurrentDocument.FieldSetText("SaveOptions", "0")

Call uidocCurrentDocument.Close

End If

--- Ende Code ---

Das Mail wird mir auch geschickt, das heisst der Status ist also eine zeit lang auf declined. Das Dokument wird aber nicht mit dem neuen Status gespeichert sondern wieder mit dem alten, also als Request.

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln