1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure
4 /*--------------------------------------------------------------------------
5 File
: trigger
/wrrntrvw.p
6 Purpose
: Update tasks to reflect reviews completed and reviews due
10 Author
(s
) : Andrew McMillan
12 ------------------------------------------------------------------------*/
13 TRIGGER PROCEDURE FOR WRITE OF RentReview
OLD OldReview.
15 /* could call workflow
/update-task.p if dates have changed
*/
17 /* _UIB-CODE-BLOCK-END
*/
21 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
23 /* ******************** Preprocessor Definitions
******************** */
25 &Scoped-define PROCEDURE-TYPE Procedure
29 /* _UIB-PREPROCESSOR-BLOCK-END
*/
34 /* *********************** Procedure Settings
************************ */
36 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
37 /* Settings for
THIS-PROCEDURE
41 Add Fields to
: Neither
42 Other Settings
: CODE-ONLY
COMPILE
44 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
46 /* ************************* Create Window
************************** */
48 &ANALYZE-SUSPEND _CREATE-WINDOW
49 /* DESIGN Window definition
(used by the UIB
)
50 CREATE WINDOW Procedure
ASSIGN
53 /* END WINDOW DEFINITION
*/
60 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure
63 /* *************************** Main Block
*************************** */
65 FIND TenancyLease
OF RentReview
NO-LOCK NO-ERROR.
66 IF AVAILABLE(TenancyLease
) THEN DO:
67 IF NEW RentReview
THEN
70 IF RentReview.ReviewStatus
<> OldReview.ReviewStatus
THEN RUN review-status-change.
71 IF RentReview.DateDue
<> OldReview.DateDue
THEN RUN review-date-change.
74 IF NOT AVAILABLE(RentReview
) THEN DO:
75 MESSAGE "Deleting rent review".
78 /* _UIB-CODE-BLOCK-END
*/
82 /* ********************** Internal Procedures
*********************** */
84 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE review-date-change Procedure
85 PROCEDURE review-date-change
:
86 /*------------------------------------------------------------------------------
88 ------------------------------------------------------------------------------*/
89 DEF VAR date-due
AS DATE NO-UNDO.
90 DEF VAR task-no
AS INT NO-UNDO.
91 DEF VAR results
AS CHAR NO-UNDO.
93 FIND FlowTask
WHERE FlowTask.DueDate
= OldReview.DateDue
94 AND FlowTask.EntityType
= "T"
95 AND FlowTask.EntityCode
= TenancyLease.TenantCode
96 AND FlowTask.FlowTaskType
= "RR" NO-LOCK NO-ERROR.
97 IF AVAILABLE(FlowTask
) THEN DO:
98 date-due
= FlowTask.DueDate.
99 task-no
= FlowTask.FlowTaskNo.
100 IF RentReview.DateDue
= ?
THEN DO:
101 FIND CURRENT FlowTask
EXCLUSIVE-LOCK NO-ERROR.
102 DELETE FlowTask
NO-ERROR.
103 FIND CURRENT FlowTask
NO-LOCK NO-ERROR.
106 RUN workflow
/update-task.p
( INPUT-OUTPUT date-due
, INPUT-OUTPUT task-no
, "MoveTask",
107 STRING(RentReview.DateDue
),
112 date-due
= RentReview.DateDue.
113 RUN workflow
/update-task.p
( INPUT-OUTPUT date-due
, INPUT-OUTPUT task-no
, "NewTask",
114 "T," + STRING(TenancyLease.TenantCode
) + ",RR",
120 /* _UIB-CODE-BLOCK-END
*/
124 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE review-status-change Procedure
125 PROCEDURE review-status-change
:
126 /*------------------------------------------------------------------------------
128 ------------------------------------------------------------------------------*/
129 DEF VAR date-due
AS DATE NO-UNDO.
130 DEF VAR task-no
AS INT NO-UNDO.
131 DEF VAR results
AS CHAR NO-UNDO.
133 FIND FlowTask
WHERE FlowTask.DueDate
= OldReview.DateDue
134 AND FlowTask.EntityType
= "T"
135 AND FlowTask.EntityCode
= TenancyLease.TenantCode
136 AND FlowTask.FlowTaskType
= "RR" NO-LOCK NO-ERROR.
137 IF AVAILABLE(FlowTask
) THEN DO:
138 date-due
= FlowTask.DueDate.
139 task-no
= FlowTask.FlowTaskNo.
140 RUN workflow
/update-task.p
( INPUT-OUTPUT date-due
, INPUT-OUTPUT task-no
, "TaskDone",
141 RentReview.ReviewStatus
,
145 /* if the date has changed then it will get fixed in the next screen
*/
146 date-due
= OldReview.DateDue.
147 RUN workflow
/update-task.p
( INPUT-OUTPUT date-due
, INPUT-OUTPUT task-no
, "NewTask",
148 "T," + STRING(TenancyLease.TenantCode
) + ",RR",
151 /* might not have been created with the right status on it
*/
152 RUN workflow
/update-task.p
( INPUT-OUTPUT date-due
, INPUT-OUTPUT task-no
, "TaskDone",
153 RentReview.ReviewStatus
,
159 /* _UIB-CODE-BLOCK-END
*/
163 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE schedule-review Procedure
164 PROCEDURE schedule-review
:
165 /*------------------------------------------------------------------------------
167 ------------------------------------------------------------------------------*/
168 IF RentReview.DateDue
= ?
THEN RETURN.
170 DEF VAR date-due
AS DATE NO-UNDO.
171 DEF VAR task-no
AS INT NO-UNDO.
172 DEF VAR results
AS CHAR NO-UNDO.
174 date-due
= RentReview.DateDue.
175 RUN workflow
/update-task.p
( INPUT-OUTPUT date-due
, INPUT-OUTPUT task-no
, "NewTask",
176 "T," + STRING(TenancyLease.TenantCode
) + ",RR",
181 /* _UIB-CODE-BLOCK-END
*/