20
Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA Esfir Livshitz, City of Pasadena, CA Doug Johnson, City of Overland Park, KS Date: Thursday October 4, 2001

Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

  • Upload
    chinue

  • View
    33

  • Download
    0

Embed Size (px)

DESCRIPTION

Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA Esfir Livshitz, City of Pasadena, CA Doug Johnson, City of Overland Park, KS Date: Thursday October 4, 2001. Agenda. Activity Scripts What are they? How do they work? Examples of what they can do - PowerPoint PPT Presentation

Citation preview

Page 1: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

Session: Activity Scripts and Triggers

Panelist: Pam Kietzman, City of Pasadena, CAEsfir Livshitz, City of Pasadena, CADoug Johnson, City of Overland Park, KS

Date: Thursday October 4, 2001

Page 2: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

2

Activity Scripts What are they? How do they work? Examples of what they can do

Triggers What are they? How do they work? Examples of what they can do

Agenda

Page 3: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

3

An activity script is a code that communicates with the Permit Plan application in order to help us enforce our business rules for activities over a broad range of cases & projects.

One example of what an activity script can do would be to check the status of a permit before taking an inspection request. This would ensure that you don’t take any inspection requests on permits that aren’t issued yet or are already finaled.

Activity Scripts – What are they?

Page 4: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

4

Each activity script contains one or more functions, and is executed one line at a time. You can include as many functions as you need in a script and repeat each of them any number of times.

After a script has been created, then you need to link the script to a specific activity of a specific case type. This is done in the Activity Script Link Table.

Activity Scripts – How do they work?

Page 5: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

5

Sample Activity Script - “AholdStat”

The activity script “AholdStat” allows us to have the system check the status of a permit to make sure it has an ISS status.

See the example to the right labeled “BLDSTAT”. If the case has anything other than an ISS status, then there is a Hold Level 3 placed against any new inspection activities being added.

An activity link has to be made to each inspection activity code, which is time intensive, but worth the investment.

Page 6: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

6

Sample Activity Script - “AaddFee”

The activity script “AaddFee” will add a fee item when the activity is added for miscellaneous services requiring their own additional charge (e.g. reinspection fees, after-hour inspections, etc.). This is a convenient method for the inspector or support staff to record that a reinspection is required, the fee will be automatically added and in Pasadena, another inspection request won’t be taken until this fee is paid…because our inspection activities are checking for unpaid fees.

Page 7: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

7

Sample Activity Script - “AholdFee”

The activity script “AholdFee” checks to make sure that there aren’t any outstanding fees within the project, even if they are all revolved on that particular case. All fees, project-wide must be paid before the activity which finals the case is allowed to be added.

The sample to the right is making sure all fees are paid before a Certificate of Occupancy is granted on a BLD case.

Page 8: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

8

Sample Activity Script - “AchngExp” (1)

The activity script “AchngExp” will push out an expiration date when an inspection is completed on permits issued by Building. The expiration date is to be extended by 180 days not only on the permit on which the inspection was performed, but for all other permits of certain case types which are attached to the same project. The stored procedure “today_6M”, which was written by Tidemark, updates not only the current permit, but all related permits per documented standards.

Page 9: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

9

Sample Activity Script - “AChngExp” (2)

Here’s another example of how to use the “AChngExp” script. The Planning case type covers all land use review applications, and the subtype field allows the tracking of each type for reporting purposes. Different planning case types may have different expiration date regulations. The activity will calculate the expiration date for a given case, based on system date and on the case subtype to which the activity pertains.

Page 10: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

10

Sample Activity Script – “AddActn”

The activity script “AaddActn” can allow you to add one activity which will then add multiple activities. Pasadena has a complex plan review process and is tracked online using different activities for each agency involved in the review. Certain combinations of plan check activities constitute standard “routes” for a given project (e.g., a Restaurant Tenant Improvement would consist of Building, Zoning, Design Review, Fire, Public Works & Health Dept reviews). A single activity is added which then adds these multiple plan review activities to the case.

Page 11: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

11

Sample Activity Script – “Adisp”

Here, the activity script “Adisp” is combined with “AaddActn” to do two things: check the disposition of an activity and based on that disposition, add another activity.Pasadena’s Water & Power department is informed by Building when a power release has been approved at a construction site. If the inspection activity for the Electrical Service is APPR, then the system will add the activity to “Release Electric to W&P” automatically. Water & Power runs a Crystal Report everyday to find out which addresses have been approved for power release.

Page 12: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

12

Sample Activity Script – “AholdActn”

The activity script “AholdActn” is used to search the current case, or any related cases designated by the extent of the search, for activities that have not been completed and/or signed off.In Pasadena, a new address cannot be finalized until the building permit on the site has been issued. The activity on our “Address Assignment” (ADD) case type, which updates the status to FNL, checks to see if the “Permit Issued” activity on the building permit, attached to the same project, has been signed off before allowing the status change on the ADD case.

Page 13: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

13

A trigger defines an action the database should take when some database-related event occurs. The action is an executable block of computer

code which can perform a variety of actions on the database (in Oracle, this code is written with PL/SQL)

The event that starts the trigger can be an update, insert or delete action on a specific database table

Triggers – What are they?

Page 14: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

14

Triggers – How do they work?

Header – trigger name, type oftrigger, table name

& “when” clauseDeclare variables (if any)

Begin trigger body

PL/SQL statements

End of trigger

Create trigger t_cond_desc Before insert on case_condition for each rowWhen (new.case_type = 'OPC' ) Declare Dvar varchar2(150); Nvar varchar2(150); cm casemain%rowtype;Begin Select * into cm from casemain Where csm_caseno = :new.csm_caseno; Nvar := rtrim(:new.csc_title, ‘ ‘);Dvar := cm.csm_description || ‘ , ‘ || Nvar;Dvar := ltrim(dvar, ‘ , ‘); Update casemain set csm_description = dvar, csm_status =

‘VIO’ where csm_caseno = :new.csm_caseno; End;

Page 15: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

15

Triggers are NOT supported by Tidemark Triggers should be written by your DBA or someone

who is VERY knowledgeable about your database Triggers must account for all table relationships and

dependencies, and for Tidemark’s “business rules” Triggers must account for all possible data values,

including NULL values Triggers should be tested thoroughly before

implementation

Disclaimer!

Page 16: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

16

Validate or modify data entry Example: Disposition field on case_action

Shortcuts to simplify user interface Example: Sign-off for conditions

Insert data into other fields or tables Example: Code violations added to csm_description

Alter system dates Example: Plan review comment letter due dates

Some Examples

Page 17: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

17

Some Pasadena Trigger Examples

Insert data into other fields or tables Example: Populate “assigned to” fields on permit case types with the

inspector’s initials based on certain parameters (e.g., commercial/residential projects or designated inspection areas).

Update records on related cases that are linked by a project Example: Push out permit expiration date on all related cases of a

project when an inspection has taken place on the project. A project may have a building, electrical, plumbing & mechanical permits. An inspection on any one of those permits should push out the expiration date by 180 days on the entire project. Pasadena has developed a trigger which will update the parent record and the child records that are attached by a project.

Page 18: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

18

Pasadena Trigger Example (1)

Populating case extended fields Example: As you can see on

the right, Pasadena has added several case_extended fields to be displayed on the main case screen. These case_extended fields would have to be updated by the user. A trigger was built so that the “Plancheck Expiration” field would be populated when the case is initially created.

Page 19: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

19

Pasadena Trigger Example (2)

Populating case extended fields Example: Another trigger that

Pasadena is working on will populate a case_extended field labeled “Approved” .

When submitted plans have been approved for permit, an activity is added to change the status to APR, but the corresponding date cannot be automatically populated via the activity setup. With this trigger, the “Approved” date field will also populate when the activity is added.

Page 20: Session: Activity Scripts and Triggers Panelist: Pam Kietzman, City of Pasadena, CA

October 2001 Tidemark User's Conference

20

Triggers cannot alter data contained in the same table as the trigger event, other than the row that initiated the trigger event

If you have more than one trigger on the same database table/event, you run the risk of code conflicts

Triggers can be used to run Oracle Stored Procedures

Tips and Traps