Hi,
I am struggling to get this agent to work in LS. I have an action on a view which is meant to set all documents which are selected to Paid, along with some other fields, and then email the person(s) to say their expense(s) has/have been paid.
The button on the form is formula language and is below:
@Command([EditDocument];“1”);
@Command([ViewRefreshFields]);
@If(Change = “Yes”; @Do(@Prompt([Ok]; “Please Confirm Change”; “Please press the Notify Change Button to confirm your change”); @Return(“”)); “”);
FIELD Cancelled:=“No”;
FIELD Decline:=“No”;
FIELD SentForApp:=“No”;
FIELD ManApproved:=“No”;
FIELD Paid:=“Yes”;
FIELD Status:=“Paid”;
FIELD LogName:=@Name([CN];@UserName);
space:= " ";
comma:=“,”;
month:=@Select(@Month(@Today);“January”;“February”;“March”;“April”;“May”;
“June”;“July”;“August”;“September”;“October”;“November”;“December”);
day:=@Text(@Day(@Today));
year:=@Text(@Year(@Today));
date:=day + space+ @Left(month;3) + space + comma + space + year;
FIELD ModifyDate:=date;
FIELD Log:= Log+@NewLine+Status+ " confirmed by “+LogName+” on " +ModifyDate;
@Command([ViewRefreshFields]);
@Command([FileSave]);
@MailSend(Name;Acccounts;CreatedBy;“Expense Form for “+Name+” Has Been Paid “;””;“This expense form has been paid by Accounts.”+@NewLine +@NewLine + “Please follow link” +@NewLine +@NewLine + “Thank you.”;[IncludeDoclink]);@PostedCommand([FileSave]) & @PostedCommand([FileCloseWindow])
This works perfectly, but now the accounts person has asked for a button on a view, so they can select more than one expense at a time, instead of having to go into each individual one. (Which makes sense). I have written an agent in LS below, but it appears to be working on one expense, but not 2 if 2 are selected.
Does anyone happen to know why? I’ve also been messing around trying lots of things, so you might find some Dim’s etc… are no longer required.
I’ve also coded out the email part as I know this is working.
I have coded out this:
’ f_log.AppendToTextList Char(10) & " Paid Confirmed by " & v_commonName & " on " & Cstr(str_Date)
as I’m not sure how to fix this. On this field, it is multivalue but does not have newline selected as I did this in formula language, I and trying to find what newline is in LS, but am also having problems. Does anyone know this?
Sub Initialize
Dim workspace As NotesUIWorkspace
Dim session As New Notessession
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As NotesDocument
Dim newdoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim uidoc As NotesUIDocument
Dim str_Date As String
Set workspace=New NotesUIWorkspace
Set db = session.currentdatabase
Set newdoc=New NotesDocument(db)
Set uidoc=workspace.currentdocument
Set rtitem=New NotesRichTextItem(newdoc,"Body")
'get the selected docs
Set col = db. UnprocessedDocuments
If col Is Nothing Then
Msgbox "none docs selected"
Exit Sub
End If
'now you have a doccollection that you can handle
Set doc = col.Getfirstdocument
While Not (doc Is Nothing)
'do anything with the doc
Dim f_log As NotesItem
Set f_log = doc.getFirstItem( "Log" )
str_Date = doc.c_Date(0)
If doc.Change(0 ) = "Yes" Then
Msgbox("Please Confirm change, Please press the Notify Change button to confirm your change.")
continue = False
End If
v_commonName = session.CommonUserName
doc.LogName=v_commonName
doc.Cancelled="No"
doc.Decline="No"
doc.SendForApp="No"
doc.ManApproved="No"
doc.Paid="Yes"
doc.Status="Paid"
doc.ModifyDate=str_Date
NameN=doc.Name(0)
’ f_log.AppendToTextList Char(10) & " Paid Confirmed by " & v_commonName & " on " & Cstr(str_Date)
doc.Save True, True
flag=doc.ComputeWithForm(False,False)
'######## Start - Coding email out as this part is working ########
’ newdoc.Form=“Memo”
’ newdoc.Subject="Expense for " & NameN & “, Has been Paid”
’ newdoc.SendTo=doc.Name
’ newdoc.CopyTo=doc.Accounts
’
’ Call rtitem.AddNewLine(1)
’ Call rtitem.AppendText(“This expense form has been paid by Accounts”)
’ Call rtitem.AddNewLine(2)
’ Call rtitem.AppendText("Please follow link to view bid ->> ")
’ Call rtitem.AppendDocLink(doc,db.Title)
’
’ Call newdoc.Send(False)
'######## End - Coding email out as this part is working ########
Set doc = col.Getnextdocument(doc)
'doc.ComputeWithForm( False, False )
'flag=doc.ComputeWithForm(False,False)
' uidoc.Refresh
' uidoc.Reload
' Call doc.Save(False, True)
' Call uidoc.Close
Wend
End Sub
Many thanks to all that read this and help.
Hayley.