-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEDRMS.lss
8221 lines (7163 loc) · 322 KB
/
EDRMS.lss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%REM
Library edrms
Created Feb-April 2015 by Dominic Shields
Description: Comments for Library
%END REM
Option Public
Option Declare
Use "logging"
' No front end classes declared globally in case it interferes with background agents, prefix everything here with edrms to prevent
' scope errors
Const EDRMSSLVERSION$ = "Version 7 - 24/10/2017 10:00" ' This indicates (if used properly) whether the correct version of the code is out there
Const DB_PROFILE_ERRORS = 1001
Const EDRMSTERM$ = "EDRMS" ' What we refer to the system as
Const EDRMSSL$ = "edrms" ' This Script Library Name
Const EDRMSPROFILENAME$ = "edrmsprofile" ' EDRMS Database Profile form name
Const EDRMSBDBPROFILENAME$ = "BDBProfile" ' BDB Profile form name
Const EDRMSMETADBPROFILENAME$ = "edrms_email_profile" ' MetaDB Profile form name
Const EDRMSSYSTEMROLES$ = "[dbadmin]:[registrar]" ' Roles with special EDRMS Access
Const EDRMSREGISTRAR$ = "[registrar]" ' Registrar
Const EDRMSDBADMIN$ = "[dbadmin]" ' dbadmin
Const EDRMSADMINS$ = "Records Management" ' Informal name for EDRMS Admins
Const EDRMSADMINSGROUP$ = "ERMS Admins" ' Notes Email/ACL group for EDRMS Admins
Const EDRMSDEVELOPERGROUP$ = "Dominic Shields" ' Simplifies testing certain functions
Const HELPDESK$ = "Service Desk" 'Current Help desk system - changed from Assyst 19/09/2016
Const NAMESNSF$ = "names.nsf" ' Notes NAB
Const LOOKUPNSF$ = "lookup.nsf" ' ONS Lookup Database
Const EDRMSNCDKEY$ = "NCD" ' Lookup Key for NCD
Const EDRMSMETADATADBKEY$ = "EDRMS MANAGEMENT DB" ' Lookup key for Management/Metadata DB
Const EDRMSHOLDINGDBKEY$ = "EDRMS HOLDING DB" ' Lookup key for Holding DB
Const EDRMSCOUNTSKEY$ = "EDRMS FILE COUNTS" ' Lookup key for File Counts (maybe not needed)
Const LOOKUPA1$ = "A1" ' ONS Lookup Database View
Const LOOKUPBDB$ = "A3" ' BDB LOOKUP.NSF VIEW
Const EDRMSNCDVIEW$ = "pnn" ' NCD People by Notes Name Abbreviated
Const EDRMSNABALLNAMES$ = "(AllNames)" ' NAB All Names view
Const EDRMSEXCEPTIONSVIEW$ = "(ERMS Exceptions)" ' View of Databases marked as exceptions in Counts DB
Const EDRMSVIEWLOGDELETE$ = "EDRMSH1" '(EDRMS Advice Logs for Deletion)
Const EDRMSVIEWLOGS$ = "EDRMSH2" '(EDRMS All Advice Logs)
Const EDRMSVIEWREVIEWEDREMAIN$ = "EDRMSH3" '(EDRMS Reviewed Records Remaining)
Const EDRMSVIEWFORREVIEW$ = "EDRMSH4" '(EDRMS Records For Review)
Const EDRMSVIEWOLDUNDECLARED$ = "EDRMSH5" '(EDRMS Undeclared Documents More Than 1 Year Old 1)
Const EDRMSVIEWTOPLEVELRECS$ = "EDRMSH6" ' (EDRMS Records Top Level Only)
Const EDRMSVIEWALLDOCSINSCOPE$ = "EDRMSH7" ' (EDRMS Docs In Scope No Hierarchy)
Const EDRMSVIEWALLUNDECLARED$ = "EDRMSH8" ' (EDRMS All Undeclared Documents)
Const EDRMSVIEWALLDECLARED$ = "EDRMSH9" ' (EDRMS All Declared Documents)
Const EDRMSVIEWDEFAULT$ = "EDRMS1" 'EDRMS\1. Everything
Const EDRMSVIEWDECLARETODAY$ = "EDRMS2" ' EDRMS\Declare Today
Const EDRMSVIEWREBUILD1$ = "EDRMS3" ' EDRMS\Undeclared Docs By Owner
Const EDRMSVIEWREBUILD2$ = "EDRMS4" ' EDRMS\Declared Records For Review Current Year By BDB Categories
Const EDRMSVIEWREBUILD3$ = "EDRMS5" ' EDRMS\Declared Records For Review Current Year By EDRMS Categories
Const EDRMSVIEWREBUILD4$ = "EDRMS6" ' EDRMS\Undeclared Records To Be Advised
Const EDRMSVIEWREBUILD5$ = "EDRMS7" ' EDRMS\Undeclared Records To Be Deleted
Const EDRMSVIEWTRANSFER$ = "EDRMS8" ' EDRMS\Undeclared Records Ready for Transfer
Const EDRMSVIEWDELETED$ = "EDRMS9" ' EDRMS\Undeclared Records Deleted Documents (Top Level)
Const EDRMSVIEWRECSNOTREQD$ = "EDRMS10" ' EDRMS\2. Declared Records Not Required
Const EDRMSVIEWREASSIGNED$ = "EDRMS11" ' EDRMS\1. Reassigned Documents
Const EDRMSVIEWAUTODECLARE$ = "EDRMSH10" ' (EDRMS Undeclared Documents Older Than Cutoff Auto Declare)
Const EDRMSVIEWAUTODELETE$ = "EDRMSH11" ' (EDRMS Undeclared Documents Older Than Cutoff Auto Delete)
Const EDRMSSECMARKING$ = "OFFICIAL SENSITIVE" ' Security Marking that can be involved
Const EDRMSTRANSFERSTATUS$ = "Ready for Transfer"
Const EDRMSAWDCAT$ = "Awaiting Deletion" ' Awaiting Deletion Category Value
Const EDRMSAWDSUBCAT$ = "Documents awaiting deletion" ' Awaiting Deletion SubCategory Value
Const EDRMSRESTCAT$ ="(Restored Documents)" ' A restored documents category
Const EDRMSDELETIONLOGFORM$ = "DelLog" ' Deletion log form
Const EDRMSDELETIONADVICELOGFORM$ = "DelAdvice" ' Deletion Advice log form
Const EDRMSLOG$ = "edrmslog" ' Audit log field name
Const EDRMSDELETELOG$ = "deletelog" ' Delete log field name
Const EDRMSMAXREPSIZE& = 30000 ' Maximum size of a report (bytes)
Const EDRMSCONFLICT$ = "$Conflict" ' Field that indicates a conflict doc
Const BFFIELD$ = "bfdate" ' Defining the BF Field 19/09/2016
' Constants containg values of days/months/years to calculate for declaration limits/deadlines
'Const EDRMS7DAYS% = -7 ' (Negative) Normally days grace with certain date adjustments
'Const EDRMS9DAYS% = -9 ' (Negative) Normally days grace with certain date adjustments
Const EDRMS15DAYS% = 15 ' Fortnight-ish calculation
Const EDRMS6WEEKS% = 42 ' Six weeks date adjust
Const EDRMSMONTHS% = 6 ' Used in one agent to deal with versions
Const EDRMSINITMONTHS% = -24 ' (Negative) Months from creation for default initial declaration
Const EDRMSMODIFIEDYEAR% = -1 ' (Negative) Years we allow modifications to delay declaration
Const EDRMSCREATEDYEAR% = -2 ' (Negative) Years absolute lmiit for delay between creation and declaration/removal
Const EDRMSCREATEDDAYS% = 730 ' The EDRMSCREATEDYEAR% expressed as days
Const EDRMSMODIFIEDDAYS% = 365 ' The EDRMSMODIFIEDYEAR% expressed as days 'rob
Dim edrmssess As NotesSession
Dim edrmsdb As NotesDatabase
Dim edrmsmetadatadb As NotesDatabase
Dim edrmsholdingdb As NotesDatabase
Dim edrmscountsdb As NotesDatabase
Dim edrmslookupnsfdb As NotesDatabase
Dim edrmsncddb As NotesDatabase
Dim edrmsnabdb As NotesDatabase
Dim edrmsview As NotesView
Dim edrmslookupnsfview As NotesView
Dim edrmslookupbdbview As NotesView
Dim edrmsdc As NotesDocumentCollection
Dim edrmsdoc As NotesDocument
Dim edrmsprofiledoc As NotesDocument
Dim edrmsbdbprofiledoc As NotesDocument
Dim edrmsmetaprofiledoc As NotesDocument
Dim edrmscurrentuser As NotesName
Dim edrmsdbservernn As NotesName
Dim edrmsmasterservernn As NotesName
Dim edrmsprofileitem As NotesItem
Dim edrmsfields() As String
Dim edrmsinitialdeclaration() As String
Dim edrmserrorstub As String
Dim edrmserrortext As String
Dim edrmsdbeditor As String
Dim edrmsdbdelete As String
Dim edrmsdoceditor As String
Dim edrmslastglobalerr As String
Dim edrmsbdbtitle As String
Dim edrmsadminsgroupmember As String
Dim edrmspreventnewdocs As string
Dim edrmsrespcount As Integer
Dim edrmsuseraccesslevel As Integer
Dim edrmsoldsecmarking As Integer
Dim edrmsmaxdeclarelimit As Integer
Dim edrmsmaxmovelimit As Integer
Dim edrmsmaxreviewlimit As Integer
Dim edrmslimitedaccessflag As integer
Dim edrmscategories As Variant
Dim edrmsretention As Variant
Dim edrmsretval As Variant
Dim edrmsusernameslist As Variant
Dim edrmssortedarray As Variant
Sub Initialize
On Error GoTo globalerrhandle
Set edrmssess = New NotesSession
Set edrmsdb = edrmssess.Currentdatabase
edrmserrorstub = edrmsdb.Title & ". Script Library: " & EDRMSSL$ & ". Sub/function "
edrmserrortext = LCase(LSI_Info(2)) & " called by " & LCase(LSI_Info(12))
Print edrmserrorstub & " " & edrmserrortext & " " & EDRMSSLVERSION$
Set edrmsdbservernn = New NotesName(edrmsdb.server)
Set edrmscurrentuser = New NotesName(edrmssess.Username)
' Find current user access level to current Database
Call edrms_get_db_access(edrmsdb,edrmsdbeditor,edrmsdbdelete,edrmsuseraccesslevel)
' GET HANDLE ON BDB PROFILE, BETTER DOING IT ONCE
Set edrmsbdbprofiledoc = edrmsdb.getprofiledocument(EDRMSBDBPROFILENAME$)
If edrmsbdbprofiledoc Is Nothing Then
If edrmssess.Isonserver Then ' Check not running on server
Print "Error: Unable to locate the BDB Profile for this database, exiting " & edrmserrorstub & edrmserrortext
logaction("Error: Unable to locate the BDB Profile for this database, exiting " & edrmserrorstub & edrmserrortext)
Else ' Put out a nicer log message
MsgBox "Error: Unable to locate the BDB Profile for this database, exiting",16,edrmserrorstub & edrmserrortext
End If
Exit Sub
End If
' GET HANDLE ON LOOKUP.NSF IF ON SERVER, BETTER DOING IT ONCE
If edrmsdb.server <> "" Then
Set edrmslookupnsfdb = New NotesDatabase(edrmsdb.server,LOOKUPNSF$)
If edrmslookupnsfdb Is Nothing Then
If Not edrmssess.Isonserver Then ' Check not running on server
MsgBox "Error: Unable to locate the Notes lookup database, exiting",16,edrmserrorstub & edrmserrortext
Else ' Put out a nicer log message
Print "Error: Unable to locate the Notes lookup database, exiting " & edrmserrorstub & edrmserrortext
End If
Exit Sub
End If
Set edrmslookupnsfview = edrmslookupnsfdb.getview(LOOKUPA1$)
Set edrmslookupbdbview = edrmslookupnsfdb.getview(LOOKUPBDB$)
End If
' GET HANDLE ON EDRMS PROFILE, BETTER DOING IT ONCE
Set edrmsprofiledoc = edrmsdb.getprofiledocument(EDRMSPROFILENAME$)
If edrmsprofiledoc.hasitem("EDRMSMasterServer") Then
If edrmsprofiledoc.EDRMSMasterServer(0) = "" Then
Call edrms_profile_setup ' If not set up then get the values from the Management/Metadata DB
End If
Else
Call edrms_profile_setup ' If not set up then get the values from the Management/Metadata DB
End If
' GET EDRMS PROFILE DOC VALUES FROM THIS Database
Set edrmsmasterservernn = New NotesName(edrmsprofiledoc.EDRMSMasterServer(0))
edrmscategories = edrmsprofiledoc.EDRMSCategories
edrmsretention = edrmsprofiledoc.EDRMSRetention
edrmsmaxdeclarelimit = edrmsprofiledoc.EDRMSMaxDeclareLimit(0)
edrmsmaxmovelimit = edrmsprofiledoc.EDRMSMaxMoveLimit(0)
edrmsmaxreviewlimit = edrmsprofiledoc.EDRMSMaxReviewLimit(0)
edrmsbdbtitle = edrmsprofiledoc.EDRMSBDBTitle(0)
' GET BDB PROFILE DOC VALUES FROM THIS DATABASE
edrmspreventnewdocs = edrmsbdbprofiledoc.preventnewdocs(0)
' DO NOT CHANGE THE ORDER OF FIELD NAMES IN THESE ARRAYS ! ADD NEW ONES TO THE END
ReDim edrmsfields(15)
edrmsfields(0) = "edrmsrecord"
edrmsfields(1) = "edrmsdate"
edrmsfields(2) = "edrmsdeclaredby"
edrmsfields(3) = "edrmscategory"
edrmsfields(4) = "edrmsinitialdeclaration"
edrmsfields(5) = "edrmsundeclarepending"
edrmsfields(6) = "edrmsreviewdate"
edrmsfields(7) = "edrmsreviewstatus"
edrmsfields(8) = "edrmsdeleteversion"
edrmsfields(9) = "edrmssourcebdbtitle"
edrmsfields(10) = "edrmssourcebdbpath"
edrmsfields(11) = "edrmsreviewedby"
edrmsfields(12) = "edrmsreviewedbydate"
edrmsfields(13) = "edrmsdelayedflag"
edrmsfields(14) = "edrmstransferdate"
edrmsfields(15) = "edrmsdeleteflag"
' Tempting to put these in a profile but two objections to that.
' They would need rolling out to every profile
' If they are changed dynamically, the consequential code would need changing anyhow
ReDim edrmsinitialdeclaration(3)
edrmsinitialdeclaration(0) = "Automatically Declare"
edrmsinitialdeclaration(1) = "Automatically Delete"
edrmsinitialdeclaration(2) = "Decide when notified"
edrmsinitialdeclaration(3) = "Declare overnight"
Exit Sub
globalerrhandle:
edrmslastglobalerr = CStr(Err) & " " & CStr(Error) & " : Line Number: " & CStr(Erl) & ": " & edrmserrorstub & " " & edrmserrortext
Print Time$ & " " & edrmslastglobalerr
Print Time$ & " " & "Check the database profile " & EDRMSPROFILENAME$ & " has all the necessary values and save it just in case"
Error DB_PROFILE_ERRORS,"Error " & edrmslastglobalerr & Chr(10) & "First check the database profile " & EDRMSPROFILENAME$ & " has all the necessary values and save it just in case"
Exit Sub
End Sub
Sub edrms_undeclare_record(doc As NotesDocument,undeclaredby As String)
On Error GoTo globalerrhandle
Const MODE$ = "UNDECLARE"
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim dcr As NotesDocumentCollection
Dim edrms_undeclare_record_errortext As String
edrms_undeclare_record_errortext = LCase(LSI_Info(2)) & " called by " & LCase(LSI_Info(12))
If(undeclaredby = "") Then
undeclaredby = edrmscurrentuser.abbreviated
End If
edrmsrespcount=0
Call edrms_undeclare_set_values(doc,undeclaredby)
Set dcr = doc.Responses
If dcr.count > 0 Then
Call edrms_recurse_responses(doc, MODE$,"",undeclaredby,Date$,Nothing,Nothing,0,0)
End If
If Not ws.currentdocument Is Nothing Then ' Allowing dual use from the open doc and from a collection of selected docs
MessageBox "Undeclared document and " & CStr(edrmsrespcount) & " responses",64, edrmsdb.title &" " & EDRMSTERM$ & " Undeclaration"
Call ws.currentdocument.close
Set uidoc = ws.EditDocument(False,doc)
End If
Exit Sub
globalerrhandle:
edrmslastglobalerr = CStr(Err) & " " & CStr(Error) & " : Line Number: " & CStr(Erl) & ": " & edrmserrorstub & " " & edrms_undeclare_record_errortext
Print Time$ & " " & edrmslastglobalerr
Error Error ' Mad but effective
Exit Sub
End Sub
Sub edrms_agent_review_recs_not_reqd(Agent As NotesAgent)
On Error GoTo errhandle
Const MODE$ = "MARKREVIEW"
Const REVIEWSTATUS$ = "Not Required"
Const VERSIONVIEW1$ = "EDRMSV1" 'SELECT (Form = "Document":"Blanksheet":"ONSLetter") & ((Version = 0 & Provversionno > 0) | (Version > 0 & Provversionno = 0)) & EDRMSReviewStatus != "Ready for Transfer"
Const VERSIONVIEW5$ = "EDRMSV5" 'SELECT (Form = "Document":"ONSLetter":"Blanksheet") & ((Version = 0 & Provversionno > 0) | (Version > 0 & Provversionno = 0)) & EDRMSReviewStatus != "Ready for Transfer"
Dim ws As New NotesUIWorkspace
Dim view As NotesView
Dim view1 As NotesView
Dim dcnotrequired As NotesDocumentCollection
Dim versiondc As NotesDocumentCollection
Dim doc As NotesDocument
Dim editdoc As NotesDocument
Dim copydoc As NotesDocument
Dim newdoc As NotesDocument
Dim origdoc As NotesDocument
Dim uidoc As NotesUIDocument
Dim msg As String
Dim msg3 As String
Dim selectstring As String
Dim doclevel As String
Dim storedsubject As String
Dim storedversion As String
Dim storedclonedfrom As String
Dim searchkey As String
Dim editoraccess As string
Dim responseflag As Integer
Dim recordflag As Integer
Dim editorlevel As Integer
Dim versiontype As Integer
Dim removefromcollection As Integer
Dim storedversionno As Integer
Dim returncode As Integer
Dim errorcnt As Integer
Dim delayedflag As integer
Dim responsereviewed As Long
Dim reviewed As Long
Dim replyval As Variant
responseflag = 0
editorlevel = 0
recordflag = 0
reviewed = 0
responsereviewed = 0
errorcnt = 0
returncode = 0
delayedflag = 0
edrmserrortext = LCase(LSI_Info(2)) & " called by " & LCase(LSI_Info(12))
Call initlog(agent.name)
Set edrmsdc = edrmsdb.unprocesseddocuments
' Firstly check that the user is eligible editor to the top level docs
logaction("Check that the user is eligible editor to the top level docs")
Set doc = edrmsdc.getfirstdocument
While Not doc Is Nothing
If Not doc.Isresponse Then
logaction("Main Document subject: " & doc.subject(0))
editoraccess = ""
Call edrms_get_doc_access(doc,editoraccess)
If editoraccess <> "Yes" Then
msg3 = "You are not an eligible editor of all the top-level selected documents, you need either higher database access or to be a named editor of the documents"
MessageBox msg3 ,16, edrmsdb.title &" " & EDRMSTERM$ & " Access Error"
logclose("User informed " & msg3)
Exit Sub
End If
End If
Set doc=edrmsdc.GetNextDocument(doc)
Wend
logaction("Calling sub edrms_review_checks which performs checks on selected docs and their responses")
Call edrms_review_checks(edrmsdc,REVIEWSTATUS$,returncode,editorlevel)
If returncode > 0 Then
logclose("Returned from edrms_review_checks with exit code " & CStr(returncode) & " user will have been informed why, exiting")
Exit Sub
End If
logaction("Main processing loop - a lot of versioning checks")
Set doc = edrmsdc.getfirstdocument
While Not doc Is Nothing
If doc.HasItem("version") Then ' This line added 07/03/12 Assyst call R229046
If doc.version(0) > 0 Then
Set view=edrmsdb.GetView(VERSIONVIEW1$)
Set view1=edrmsdb.GetView(VERSIONVIEW5$)
versiontype = 0 ' 1 = top of chain, 2 = middle, 3 = bottom of chain, 4 = breaks chain
removefromcollection = 0
If doc.clonedfrom(0) <> "" And doc.clonedto(0) = "" Then ' Document top of the versioning chain
On Error 4091 Resume Next
Set origdoc = edrmsdb.getdocumentbyunid(doc.clonedfrom(0))
Set versiondc=view.GetAllDocumentsByKey(doc.cloneref(0),True)
If versiondc.Count = 2 Then
versiontype = 4
If Not origdoc Is Nothing Then
origdoc.clonedto = ""
origdoc.version = 0
origdoc.versionno = 0
End If
Set copydoc = New NotesDocument(edrmsdb)
Call doc.CopyAllItems(copydoc,True)
' Check if the document being deleted is the master clone record. If it isn't, then it needs switching to preserve any doc links...
If doc.cloneref(0) = doc.UniversalID And Not origdoc Is Nothing Then
Call origdoc.CopyAllItems(doc,True)
origdoc.edrmsreviewstatus = EDRMSTRANSFERSTATUS$
origdoc.edrmsdeleteversion = "Yes"
Call origdoc.Save(True,True)
removefromcollection = 1
End If
Call doc.Save(True,True)
Else
versiontype = 1
On Error 4091 Resume Next
Set origdoc = edrmsdb.getdocumentbyunid(doc.clonedfrom(0))
If Not origdoc Is Nothing Then
storedsubject = origdoc.subject(0)
storedversion = origdoc.version(0)
storedversionno = origdoc.versionno(0)
storedclonedfrom = origdoc.clonedfrom(0)
Set copydoc = New NotesDocument(edrmsdb)
Call doc.CopyAllItems(copydoc,True)
Call origdoc.CopyAllItems(doc,True)
doc.clonedto = ""
origdoc.edrmsreviewstatus = EDRMSTRANSFERSTATUS$
origdoc.edrmsdeleteversion = "Yes"
Call origdoc.Save(True,True)
Call doc.Save(True,True)
removefromcollection = 1
End If
End If
ElseIf doc.clonedto(0) <> "" And doc.clonedfrom(0) <> "" Then ' Document middle of the versioning chain
On Error 4091 Resume Next
Set origdoc = edrmsdb.getdocumentbyunid(doc.clonedfrom(0))
Set newdoc = edrmsdb.getdocumentbyunid(doc.clonedto(0))
If Not origdoc Is Nothing And Not newdoc Is Nothing Then
versiontype = 2
origdoc.clonedto = doc.clonedto(0)
newdoc.clonedfrom = doc.clonedfrom(0)
Call origdoc.Save(True,True)
Call newdoc.Save(True,True)
End If
ElseIf doc.clonedto(0) <> "" And doc.clonedfrom(0) = "" Then ' Document bottom of the versioning chain
searchkey = doc.Universalid
Set newdoc = view1.getdocumentbykey(searchkey,True)
' Check to see if this deletion breaks the versioning chain...
Set versiondc=view.GetAllDocumentsByKey(doc.cloneref(0),True)
If versiondc.Count = 2 Then
versiontype = 4
Else
versiontype = 3
End If
If versiontype = 4 Then
newdoc.clonedto = ""
newdoc.version = 0
newdoc.versionno = 0
newdoc.clonedfrom = ""
Else
newdoc.clonedfrom = ""
End If
Call newdoc.Save(True,True)
End If
End If
End If
If removefromcollection = 0 Then
Set editdoc = doc
Else
Set editdoc = copydoc
doc.clonedfrom = storedclonedfrom
Call doc.Save(True,True)
removefromcollection = 0
End If
editdoc.edrmssourcebdbtitle = edrmsdb.Title
editdoc.edrmssourcebdbpath = edrmsdb.filepath
Call edrms_mark_review_status(editdoc,REVIEWSTATUS$,reviewed,edrmscurrentuser.abbreviated,"","")
logaction("Main doc marked as " & REVIEWSTATUS$ &" " & editdoc.subject(0))
' RECURSE RESPONSES HERE
If editorlevel = 0 Then ' Current user is eligible editor to all responses
logaction("Recursing response thread")
edrmslimitedaccessflag = 0
Call edrms_recurse_responses(editdoc,MODE$,REVIEWSTATUS$,edrmscurrentuser.abbreviated,"",Nothing,Nothing,responsereviewed,errorcnt)
If edrmslimitedaccessflag = 1 Then
editdoc.edrmsdelayedflag = 3
editdoc.edrmsreviewstatus = EDRMSTRANSFERSTATUS$
Call editdoc.save(True,True)
Call logaction(editdoc.subject(0) & " has limited access responses which will need updating overnight, delayed flag set")
delayedflag = 1 ' Indicates to the code below that there is not full author access
End If
Else
logaction("User does not have high enough access to recurse response thread so delayed flag set")
editdoc.edrmsdelayedflag = 3
editdoc.edrmsreviewstatus = EDRMSTRANSFERSTATUS$
Call editdoc.save(True,True)
delayedflag = 1 ' Indicates to the code below that there is not full author access
End If
Set doc=edrmsdc.GetNextDocument(doc)
Wend
Call edrms_review_report(REVIEWSTATUS$,responsereviewed,errorcnt,reviewed,msg) ' THIS STATUS AND THE SUB CALLED NEEDS EXAMINING FOR INCONSISTENCIES
logaction("User Messagebox : " & msg)
' If the user has author access to all docs Move marked documents from this view to a holding view, ready for the agent to move the record to the edrms Management database
If delayedflag = 0 then
selectstring = "edrmsreviewstatus = """ & REVIEWSTATUS$ & """"
logaction("Setting the dcnotrequired documentcollection with query " & selectstring)
Set dcnotrequired = edrmsdb.search (selectstring$,Nothing,0)
If dcnotrequired.count > 0 Then
logaction("Updating the dcnotrequired documentcollection which contains " & CStr(dcnotrequired.count) & " documents, setting field edrmsreviewstatus to " & EDRMSTRANSFERSTATUS$ & " where user is eligible author")
Set doc = dcnotrequired.getfirstdocument
While Not doc Is Nothing
Call edrms_get_doc_access(doc,editoraccess)
If editoraccess = "Yes" Then
doc.edrmsreviewstatus = EDRMSTRANSFERSTATUS$
doc.save false,False
End if
Set doc = dcnotrequired.getnextdocument(doc)
Wend
End If
Else
logaction("Current user does not have author access to update all docs in the documentcollection or there are limited access responses they cannot access " & selectstring)
logaction("Processing all " & CStr(edrmsdc.count) & " top level documents in the collection to ensure they have the delayed flag set to 3")
Set doc = edrmsdc.getfirstdocument
While Not doc Is Nothing
Call edrms_get_doc_access(doc,editoraccess)
If editoraccess = "Yes" Then
doc.edrmsreviewstatus = EDRMSTRANSFERSTATUS$
doc.edrmsdelayedflag = 3
doc.save False,False
End If
Set doc = edrmsdc.getnextdocument(doc)
Wend
End if
If doclevel = "Yes" Then
Set uidoc=ws.currentdocument
Call uidoc.close
Else
Call edrms_deselect_docs(ws)
End If
Call ws.viewrefresh
Call logclose("Ends OK")
Exit Sub
errhandle:
Call logerror(Err, Error, Erl, LSI_Info(2), LSI_Info(12), " Last module before this call " & edrmserrortext ) ' LOGS HELPFUL DETAIL ON AN ERROR
Call logaction(" Last Global Error " & edrmslastglobalerr)
Call alerterrors(agent.name ,"Error") ' EMAILS THE ERROR ALERT TO ADDRESS IN PROFILE
Exit Sub
End Sub
Sub edrms_agent_review_advice_only(Agent As NotesAgent)
' This processes documents in the view pointed to by global constant EDRMSVIEWFORREVIEW$ which selects the documents in scope
' Converted Email Text Lookups to profile on Management DB
' Extensively rewritten to handle people who are still ONS Staff but the names on the declared record are not the current ONS hierarchy of SITE/ONS DJS 17/12/2015
On Error GoTo errhandle
Const NABFN$ = "FN"
Const COUNTSFORM$ = "EDRMS Count"
Dim view As NotesView
Dim metadataview As NotesView
Dim ncdview As NotesView
Dim nabview As NotesView
Dim checknabview As NotesView
Dim checknabvc As NotesViewEntryCollection
Dim nabdc As NotesDocumentCollection
Dim doc As NotesDocument
Dim doc1 As NotesDocument
Dim countdoc As NotesDocument
Dim nabdoc As NotesDocument
Dim notifymail As NotesDocument
Dim notifymailnoncd As NotesDocument
Dim repdoc As NotesDocument
Dim checknabdoc As NotesDocument
Dim acl As NotesACL
Dim getentry As NotesACLEntry
Dim rtitem As NotesRichTextItem
Dim rtitem1 As NotesRichTextItem
Dim repitem As NotesItem
Dim rsnormal As NotesRichTextStyle
Dim rs1 As NotesRichTextStyle
Dim rs2 As NotesRichTextStyle
Dim rs3 As NotesRichTextStyle
Dim rolename As NotesName
Dim storedname As NotesName
Dim name2 As NotesName
Dim ncdname As NotesName
Dim checkauthor As NotesName
Dim namefieldout As NotesName
Dim sendto() As string
Dim edrmsview As String
Dim staffreplist As String 'for list of people who had emails sent to them for deletion report
Dim storesreplist As String 'for list of people who could not be found on NCD so email was sent to Stores/[Registrar] role for deletion report
Dim regrolelist As String ' for list of people who hold registrar role
Dim groupname As String
Dim selectstring As String
Dim storedsubject As String
Dim whosdocs As String
Dim subject As String
Dim xsubject As String
Dim emailtext As String
Dim aclcount As Integer
Dim a As Integer
Dim runtype As Integer
Dim sent As Integer
Dim advicecount As Integer
Dim loggednotnab As Integer
Dim advicecountreassign As Integer
Dim advicecountnoncd As Integer
Dim emailssent As Integer
Dim emailssentnoncd As Integer
Dim docsadvised As Integer
Dim docsadvisednoncd As Integer
Dim itemcount As Integer
Dim itemcountnoncd As Integer
Dim registrarflag As Integer
Dim notonnab As Integer
Dim reassignflag As Integer
Dim owneddocs As Integer
Dim helperdbsret As Integer
Dim replyval As Variant
Dim continue As Boolean
staffreplist = ""
storesreplist = ""
regrolelist = ""
aclcount = 0
a = 0
sent = 0
advicecount = 0
advicecountreassign = 0
advicecountnoncd = 0
emailssent = 0
docsadvised = 0
docsadvisednoncd = 0
emailssentnoncd = 0
If edrmssess.Isonserver Then
If (edrmsdbservernn.common <> edrmsmasterservernn.common) Then
Exit Sub ' When run scheduled, not on master server so exit
End If
End If
edrmserrortext = LCase(LSI_Info(2)) & " called by " & LCase(LSI_Info(12))
Call initlog(agent.name)
' Call the function that gets the required external DBS
logaction("Getting DB handles to edrmsncddb, edrmsnabdb, edrmsmetadatadb, edrmsholdingdb, edrmscountsdb")
helperdbsret = edrms_get_helper_dbs
If helperdbsret > 0 Then
logaction("Error getting one or more of the required external databases, check the Lookup.nsf and the default accesses to these DBs, error code = " & CStr(helperdbsret))
logaction("Error codes: NCD = 99, NAB = 98, EDRMS Management DB = 97, EDRMS Holding DB = 96, EDRMS Counts DB = 95")
Call alerterrors(agent.name ,"Error with external databases, error code " & CStr(helperdbsret))
Exit Sub
End If
Set nabview = edrmsnabdb.getview(EDRMSNABALLNAMES$)
If nabview Is Nothing Then
logaction("Error getting " & edrmsnabdb.title & " view " & EDRMSNABALLNAMES$)
Exit Sub
End If
Set checknabview = edrmsnabdb.GetView(NABFN$)
If checknabview Is Nothing Then
logaction("Error getting " & edrmsnabdb.title & " view " & NABFN$)
Exit Sub
End If
Set ncdview = edrmsncddb.getview(EDRMSNCDVIEW$)
If ncdview Is Nothing Then
logaction("Error getting " & edrmsncddb.title & " view " & EDRMSNCDVIEW$)
Exit Sub
End If
Set view = edrmsdb.getview(EDRMSVIEWFORREVIEW$)
logaction(view.name & " contains " & CStr( view.Toplevelentrycount) & " documents")
Set doc = view.getfirstdocument ' Read ahead - note this for later
GoSub setupreport ' Note that the agent can exit in this subroutine if no docs to process so will not necessarily return from there
GoSub setupemail ' Set up the email layout
reDim sendto(0)
Call edrms_examine_acl_roles(ncdview,repitem,EDRMSREGISTRAR$,sendto,regrolelist) ' get the list of DB registrars
If ubound(sendto) = 0 And sendto(UBound(sendto)) = "" Then
logaction("Error after Call edrms_examine_acl_roles - there were no people on the ACL with the " & EDRMSREGISTRAR$ & " role, adding " & EDRMSADMINSGROUP$ & " so that processing can continue")
sendto(0) = EDRMSADMINSGROUP$
End If
If(regrolelist <> "") Then ' Indicating use Registrars List
logaction("Database Registrars ACL Role held by the following people " & regrolelist) ' Indicating use Registrars List
logaction("sendto variable contains " & CStr(UBound(sendto)) & " elements") ' Indicating use Registrars List
aclcount = 1 ' Indicating use Registrars List
End If
logaction("Setup complete, checking whether run by user or scheduled")
If edrmssess.Isonserver Then
runtype = 6 ' Setting the variable indicating Live Run
logaction("Running scheduled")
Else
Call edrms_user_live_test_prompt(view,name2,runtype,continue)
If continue = False Then
logclose("Run Ends, user aborted")
Exit Sub
End If
End If
Set doc1 = doc ' setting another handle to the first read doc in the view
storedsubject = doc.subject(0)
If doc.Reassign_To(0) = "" Then
whosdocs = doc.permanentauthor(0)
Else
whosdocs = doc.Reassign_To(0)
End If
Set storedname = New NotesName(whosdocs)
If storedname.common = "" Then
Set storedname = New NotesName(doc.authors(0)) ' Added for documents where PermanentAuthor field is not present...
End If
itemcount = 1
itemcountnoncd = 0
Set doc=view.getnextdocument(doc)
While Not doc Is Nothing
' Check that doc creator still on NAB
If doc.Reassign_To(0) = "" Then
Set ncdname = New NotesName(doc.permanentauthor(0))
Else
Set ncdname = New NotesName(doc.Reassign_To(0))
End If
If ncdname.common = "" Then
Set ncdname = New NotesName(doc.authors(0)) ' Added for documents where PermanentAuthor field is not present...
End If
notonnab = 0
Set nabdoc = nabview.getdocumentbykey(ncdname.canonical,True) ' EDRMSNABALLNAMES$ = "(AllNames)" NAB All Names view
If nabdoc Is Nothing Then
notonnab = 1
If loggednotnab = 0 Then
logaction("Not found on NAB " & ncdname.abbreviated) ' we only want this message once
loggednotnab = 1
End If
Else
loggednotnab = 0
If Left(ncdname.common,3) = "Fax" And Right(ncdname.common,7) = "Gateway" Then
notonnab = 1
End If
End If
If doc.Reassign_To(0) = "" Then
If doc.permanentauthor(0) <> "" Then
Set checkauthor = New NotesName(doc.permanentauthor(0))
Else
Set checkauthor = New NotesName(doc.authors(0))
End If
Else
Set checkauthor = New NotesName(doc.Reassign_To(0))
End If
' If checkauthor.abbreviated = storedname.abbreviated Then ' multiple entries
If checkauthor.common = storedname.common Then ' multiple entries
If notonnab = 1 Then
GoSub write_doc_line_noncd_multi
Else
If itemcount = 1 Then ' write header and first software line
Set notifymail = New NotesDocument(edrmsdb)
notifymail.importance = "1"
Set rtitem = New NotesRichTextItem( notifymail, "Body" )
GoSub write_header_line
GoSub write_doc_line
Else ' just write current name line
GoSub write_doc_line
End If
End If
Else ' single name or end of multi name
' temp NCD recheck on doc1...
loggednotnab = 0
If doc1.Reassign_To(0) = "" Then
Set ncdname = New NotesName(doc1.permanentauthor(0))
Else
Set ncdname = New NotesName(doc1.Reassign_To(0))
End If
' Added for documents where PermanentAuthor field is not present...
If ncdname.common = "" Then
Set ncdname = New NotesName(doc1.authors(0))
End If
notonnab = 0
Set nabdoc=nabview.getdocumentbykey(ncdname.canonical,True) ' EDRMSNABALLNAMES$ = "(AllNames)" NAB All Names view
If nabdoc Is Nothing Then
notonnab = 1
Else
If Left(ncdname.common,3) = "Fax" And Right(ncdname.common,7) = "Gateway" Then
notonnab = 1
End If
End If
If notonnab = 1 Then
GoSub write_doc_line_noncd
If doc.Reassign_To(0) = "" Then
whosdocs = doc.permanentauthor(0)
Else
whosdocs = doc.Reassign_To(0)
End If
Set storedname = New NotesName(whosdocs)
storedsubject = doc.subject(0)
' Added for documents where PermanentAuthor field is not present...
If storedname.common = "" Then
Set storedname = New NotesName(doc.authors(0))
End If
Else
If itemcount = 1 Then ' single item
Set notifymail = New NotesDocument(edrmsdb)
notifymail.importance = "1"
Set rtitem = New NotesRichTextItem( notifymail, "Body" )
GoSub write_header_line
GoSub write_doc_line
Else ' add the last line in and send the email
GoSub write_doc_line
End If
notifymail.Subject = subject
registrarflag = 0
Set nabdoc = nabview.GetDocumentByKey(storedname.canonical,True) ' EDRMSNABALLNAMES$ = "(AllNames)" NAB All Names view
If nabdoc Is Nothing Then
notonnab = 1
logaction("Failed to find " & storedname.canonical & " on the NAB, substituting with database registrars " & regrolelist)
notifymail.sendto = SendTo()
notifymail.Subject = subject & " Intended Addressee not found " & storedname.Abbreviated ' indicate to registrars who this should be for
registrarflag = 1
Else
Set namefieldout = New NotesName(nabdoc.owner(UBound(nabdoc.owner)))
notifymail.sendto = namefieldout.abbreviated
End If
notifymail.principal = EDRMSADMINSGROUP$
notifymail.displaysent = "Scheduled agent. Please do not respond."
GoSub write_body
If runtype = 7 Then ' TEST MODE
Call rtitem.AddNewLine( 2 )
Call rtitem.appendstyle(rs3)
If registrarflag = 1 Then ' NAB Failure above
Call rtitem.AppendText("(In live situation, this email would be redirected to the registrars " & regrolelist)
logaction("In live situation, this email would be redirected to the registrars " & regrolelist)
notifymail.Subject = subject & " Addressee in a Live Run: " & regrolelist
Else
Call rtitem.AppendText("(In live situation, this email would go to " & namefieldout.abbreviated)
logaction("In live situation, this email would go to " & namefieldout.abbreviated)
notifymail.Subject = subject & " Addressee in a Live Run: " & namefieldout.abbreviated
End If
notifymail.sendto = name2.abbreviated ' MAIL ADDRESSED TO TEST RECIPIENT IN TEST MODE
End If
emailssent = emailssent + 1
logaction("Sending mail to " & notifymail.sendto(0))
Call notifymail.Send( False ) ' MAIL SENT HERE
If doc.Reassign_To(0) = "" Then
whosdocs = doc.permanentauthor(0)
Else
whosdocs = doc.Reassign_To(0)
End If
Set storedname = New NotesName(whosdocs)
storedsubject = doc.subject(0)
If storedname.common = "" Then
Set storedname = New NotesName(doc.authors(0)) ' Added for documents where PermanentAuthor field is not present...
End If
sent = sent + 1
itemcount = 1
End If
End If
Set doc1=doc
Set doc=view.getnextdocument(doc)
Wend
endlab:
' Send the final emails
' Send normal email - don't send if last record not on NAB
notonnab = 0
Set nabdoc=nabview.getdocumentbykey(storedname.canonical,True) ' EDRMSNABALLNAMES$ = "(AllNames)" NAB All Names view
If nabdoc Is Nothing Then
notonnab = 1
If loggednotnab = 0 Then
logaction("Not found on NAB " & storedname.abbreviated)
End If
Else
If Left(ncdname.common,3) = "Fax" And Right(ncdname.common,7) = "Gateway" Then
notonnab = 1
End If
End If
If notonnab = 0 Then
If itemcount = 1 Then
Set notifymail = New NotesDocument(edrmsdb)
notifymail.importance = "1"
Set rtitem = New NotesRichTextItem( notifymail, "Body" )
GoSub write_header_line
GoSub write_doc_line
Else
GoSub write_doc_line
End If
notifymail.Subject = subject
Set nabdoc=nabview.GetDocumentByKey(storedname.canonical,True)
Set namefieldout = New NotesName(nabdoc.owner(UBound(nabdoc.owner)))
notifymail.sendto = namefieldout.abbreviated
notifymail.principal = EDRMSADMINSGROUP$
notifymail.displaysent = "Scheduled agent. Please do not respond."
Call rtitem.AddNewLine( 1 )
GoSub write_body
If runtype = 7 Then
Call rtitem.AddNewLine( 2 )
Call rtitem.appendstyle(rs3)
Call rtitem.AppendText("(In live situation, this email would go to " + storedname.common + ")")
logaction("FINAL EMAIL: In live situation, this email would go to " & storedname.common)
notifymail.sendto = name2.abbreviated
End If
emailssent = emailssent + 1
logaction("Sending final mail to " & notifymail.sendto(0))
Call notifymail.Send( False ) ' MAIL SENT HERE
sent = sent + 1
End If
' If the last document relates to someone not on NCD, write details of that record
If doc1.Reassign_To(0) = "" Then
whosdocs = doc1.permanentauthor(0)
Else
whosdocs = doc1.Reassign_To(0)
End If
Set ncdname = New NotesName(whosdocs)
If ncdname.common = "" Then
Set ncdname = New NotesName(doc1.authors(0))
End If
Set nabdoc = nabview.getdocumentbykey(storedname.canonical,True) ' EDRMSNABALLNAMES$ = "(AllNames)" NAB All Names view
If nabdoc Is Nothing Then
notonnab = 1
GoSub write_doc_line_noncd
End If
If itemcountnoncd > 0 Then
If runtype = 6 Then
If aclcount = 0 Then
' nobody on acl with [registrar] - live run - send to Admins
notifymailnoncd.SendTo = EDRMSADMINSGROUP$
Else
notifymailnoncd.SendTo = SendTo() ' This is the array of registrars passed out of edrms_examine_acl_roles
logaction("Addressing email to registrars: " & regrolelist)
End If
Else 'test run
If aclcount = 0 Then
' nobody on acl with [registrar] - test run - send to selected name
notifymailnoncd.SendTo = name2.common
Else
notifymailnoncd.SendTo = name2.common
End If
End If
notifymailnoncd.principal = EDRMSADMINSGROUP$
notifymailnoncd.displaysent = "Scheduled agent. Please do not respond."
Call rtitem1.AddNewLine( 1 )
Call rtitem1.AppendStyle(rsnormal)
If docsadvisednoncd > 1 Then
Call rtitem1.appendtext("These " + CStr(docsadvisednoncd) + " records are due for review on this BDB " & edrmsdb.Title & " ===> ")
Else
Call rtitem1.appendtext("This record is due for review on this BDB " & edrmsdb.Title & " ===> ")
End If
Call rtitem1.AppendDocLink(edrmsdb,edrmsdb.Title)
Call rtitem1.addnewline(2)
Call rtitem1.AppendText(edrmsmetaprofiledoc.regemailtext2(0))
If runtype = 7 Then
Call rtitem1.AddNewLine( 2 )
Call rtitem1.appendstyle(rs3)
Call rtitem1.AppendText("(In live situation, this email would go to Database Registrar(s) " + regrolelist$ + ")")
End If
emailssentnoncd = emailssentnoncd + 1
logaction("Sending mail about not found on NAB to " & notifymailnoncd.sendto(0))
Call notifymailnoncd.Send( False ) ' MAIL SEND
sent = sent + 1
End If
If staffreplist$ = "" Then
staffreplist$ = "No staff notification emails sent"
End If
If aclcount = 0 Then ' nobody on acl with [registrar]
repdoc.StaffDetails = staffreplist$
repdoc.StoresDetails = storesreplist$
Call repdoc.save(True,False)
Else
repdoc.StaffDetails = staffreplist$
repdoc.RoleDetails = storesreplist$
Call repdoc.save(True,False)
End If
emailtext = " email(s) sent"
logaction("End of advice run. " + CStr(sent) & emailtext)