kali958
asked on
Save current document and open a new document
I have a form for procedures, and there is a button that says Update Procedure, what I would like it to do is put the status of Archive on the current Procedure and then open up another form that inherits the data and let the user edit that document. (we have to archive the current procedure without changes due to the workflow and if we are audited on our procedures.) I can get it to archive the current form and open a new form with the data, but I would really like it to close the first form. Everytime that I put in @Command([FileCloseWindow] ) on the button, it fails. Is there something I am missing, this is my current code I am using on the Action
@If(!@Command([ViewRefresh Fields]);@ Return("") ;"");
FIELD AllowClose := "1";
FIELD SaveOptions:="1";
FIELD End_Date:=@Now;
FIELD Status :="Archived";
FIELD Person := @If(Person="";@Name([CN];@ UserName); @Name([CN] ;@UserName ):Person);
FIELD Action := @If(Action="";"Archived";" Archived": Action);
FIELD ActionDate := @If(ActionDate="";@Now;@No w:ActionDa te);
@PostedCommand([FileSave]) ;
@PostedCommand([Compose];" P_2");
@Command([ViewRefreshField s])
I have tried putting the @Command([FileCloseWindow] ) before and after the Compose and I have also tried it as a @PostedCommand.
Thanks!
@If(!@Command([ViewRefresh
FIELD AllowClose := "1";
FIELD SaveOptions:="1";
FIELD End_Date:=@Now;
FIELD Status :="Archived";
FIELD Person := @If(Person="";@Name([CN];@
FIELD Action := @If(Action="";"Archived";"
FIELD ActionDate := @If(ActionDate="";@Now;@No
@PostedCommand([FileSave])
@PostedCommand([Compose];"
@Command([ViewRefreshField
I have tried putting the @Command([FileCloseWindow]
Thanks!
ASKER
I am in ND 7 and my scripting ability is less then my Formula ability - that is why I was trying it in that, but I am open to trying to script it.
Notes does not like to continue running code after the window that contains the code has closed.
You need to move the code to an agent so that it can complete execution after the form closes.
In the action, place this code...
@Command([RunAgent]; "SaveAndNew")
Create an agent named "SaveAndNew" (Hidden, Target=None) and paste this code...
FIELD AllowClose := "1";
FIELD SaveOptions:="1";
FIELD End_Date:=@Now;
FIELD Status :="Archived";
FIELD Person := @If(Person="";@Name([CN];@ UserName); @Name([CN] ;@UserName ):Person);
FIELD Action := @If(Action="";"Archived";" Archived": Action);
FIELD ActionDate := @If(ActionDate="";@Now;@No w:ActionDa te);
@Command([FileSave]);
@Command([CloseWindow]);
@Command([Compose];"P_2");
NOTE: Unfortunately, ViewRefreshFields does not return anything, so I removed the first line from this example.
You need to move the code to an agent so that it can complete execution after the form closes.
In the action, place this code...
@Command([RunAgent]; "SaveAndNew")
Create an agent named "SaveAndNew" (Hidden, Target=None) and paste this code...
FIELD AllowClose := "1";
FIELD SaveOptions:="1";
FIELD End_Date:=@Now;
FIELD Status :="Archived";
FIELD Person := @If(Person="";@Name([CN];@
FIELD Action := @If(Action="";"Archived";"
FIELD ActionDate := @If(ActionDate="";@Now;@No
@Command([FileSave]);
@Command([CloseWindow]);
@Command([Compose];"P_2");
NOTE: Unfortunately, ViewRefreshFields does not return anything, so I removed the first line from this example.
ASKER
It works, but it does not inherit the information on the P_2 form, that is the only hitch, but it did archive the primary document and close it and then open the new P_2 form. I do have the document set to inherit existing information.
Maybe I just need two buttons, one to create and inherit and then one to close the archived document?
Maybe I just need two buttons, one to create and inherit and then one to close the archived document?
SOme sample code that shows how to manipulate fields in a doc via a button
Sub Click(Source As Button)
Dim doc As notesdocument
Dim uidoc As notesuidocument
Dim ws As New notesuiworkspace
Dim sTime As String, stime1 As String
Dim evalTotal As Variant, WeekTotal As Variant
Dim Date2 As Variant , DT3 As Variant ' NotesDateTime
Dim LngDiff As Long, i_loop As Integer
Dim opts(4) As Variant
Dim askme As Variant , Brk_time As String, dailybrk As Integer
'
' Total the Time fields
' V 0.87 6/6/06 added Break Time field.
Set uidoc=ws.currentDocument
Set doc=uidoc.Document
WeekTotal =0
opts(0) = "0 Minutes per day" ' v 0.87 next 12 lines until dailybrk
opts(1) = "15"
opts(2) = "30"
opts(3) = "45"
opts(4) = "60"
askme = ws.Prompt (PROMPT_OKCANCELLIST, _
"Daily Break for Meals in minutes", "Select 1.option please:.", opts(0), opts)
If Not Isempty (askme) Then
Brk_time = askme
' Messagebox "Meal Time: " + Brk_time
Else
Exit Sub
End If
Call doc.ReplaceItemValue("M_br k",Brk_tim e)
dailybrk= Cint( Brk_time)' part of an hour
' Messagebox "Meal Time: " + "," + Cstr(dailybrk)
' deleted code to set WeekTotal value
Call doc.ReplaceItemValue("tm_T otal",Week Total)
uidoc.reload
End Sub
Sub Click(Source As Button)
Dim doc As notesdocument
Dim uidoc As notesuidocument
Dim ws As New notesuiworkspace
Dim sTime As String, stime1 As String
Dim evalTotal As Variant, WeekTotal As Variant
Dim Date2 As Variant , DT3 As Variant ' NotesDateTime
Dim LngDiff As Long, i_loop As Integer
Dim opts(4) As Variant
Dim askme As Variant , Brk_time As String, dailybrk As Integer
'
' Total the Time fields
' V 0.87 6/6/06 added Break Time field.
Set uidoc=ws.currentDocument
Set doc=uidoc.Document
WeekTotal =0
opts(0) = "0 Minutes per day" ' v 0.87 next 12 lines until dailybrk
opts(1) = "15"
opts(2) = "30"
opts(3) = "45"
opts(4) = "60"
askme = ws.Prompt (PROMPT_OKCANCELLIST, _
"Daily Break for Meals in minutes", "Select 1.option please:.", opts(0), opts)
If Not Isempty (askme) Then
Brk_time = askme
' Messagebox "Meal Time: " + Brk_time
Else
Exit Sub
End If
Call doc.ReplaceItemValue("M_br
dailybrk= Cint( Brk_time)' part of an hour
' Messagebox "Meal Time: " + "," + Cstr(dailybrk)
' deleted code to set WeekTotal value
Call doc.ReplaceItemValue("tm_T
uidoc.reload
End Sub
See the Design help for methods connected to notesuidocument, and how to close etc.
I hope this helps !
I hope this helps !
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Re: Can't be done with @Formula language...
Sorry, I left my form name in the agent code, you'll need to replace "SaveAndNew" with "P_2" in the LotusScript part.
Sorry, I left my form name in the agent code, you'll need to replace "SaveAndNew" with "P_2" in the LotusScript part.
ASKER
THANK YOU BILL - Brilliant as usual, totally worked great!!! That is so what I need it to do. That way the org. document is archived and the new doc inherits what it needs and the user can submit their changes. Thanks again
2) I would do this in Script, rather than @functions, since it gives you more control.
I hope this helps !