You can create a MaxBasic script to record any changes to documents and save these to a table. This can be used for version control, so you can see what changes have been made to documents, and who made the changes and when.
Note: You can also use Tracking to record changes to fields in Accredo Tables.
In this example we show you how to track changes made to OE Orders. You can modify the script to track changes to other document types.
No. |
Name |
Type |
Domain |
Size |
1 |
Module |
String |
Module Code |
2 |
2 |
ID |
String |
Document No |
12 |
3 |
PropertyName |
String |
Custom |
30 |
4 |
OldValue |
String |
Custom |
30 |
5 |
NewValue |
String |
Custom |
30 |
6 |
ModifiedDate |
Date |
|
|
7 |
ModifiedTime |
Time |
|
|
8 |
ModifiedUser |
String |
CO User Code |
30 |
Alt+G). The code to create the memory table will be generated and shown in the Script Editor.Dim Form as Object
Form = GetTriggerObject 'This sets Form to the OE Order Entry form that will call this script
If Form.WasInserting = False Then 'Check that this is not a new Order being entered
Dim PrevOrder as Object
Dim ChangeList as Object
PrevOrder = CreateObject("Accredo.OEOrderData")
If PrevOrder.FindExact(Form.DocumentID) Then 'Find the previously saved order in the OEOrderData table
ChangeList = ComparePropertyValues(Form, PrevOrder) 'Compare this order and the previously saved order
For I = 0 to ChangeList.Count - 1
tblMem1.Insert
tblMem1.Module = Form.SourceModule
tblMem1.ID = Form.DocumentID
tblMem1.PropertyName = ChangeList.Item(I)
tblMem1.OldValue = Eval("PrevOrder." & ChangeList.Item(I)) 'The property value for the PrevOrder
tblMem1.NewValue = Eval("Form." & ChangeList.Item(I)) 'The property value on the form
tblMem1.ModifiedDate = SystemDate
tblMem1.ModifiedTime = Time
tblMem1.ModifiedUser = User.LoginUserName
tblMem1.Next
Next I
BrowseDataset(tblMem1)
End If
End If
Note: You can later comment out the BrowseDataset(tblMem1) line if you don't want to see the dataset after each save.
Alt+K) to check and save the code. Give the script a name like OEOrderCompareBeforeSave. The script will be saved as OEOrderCompareBeforeSave.pfs. Close the Script Editor.Field |
Value |
Module |
OE |
Class |
OESalesOrderEntryForm |
Type |
BeforeSave |
Script Name |
Select the file name saved, such as OEOrderCompareBeforeSave.pfs |
F9).