3/22/2010

Linking Zoning Permits To A Building Permit

This script was designed to enable a customer to keep better tabs on permits in other databases that are somehow associated with a given building permit. The example used here is a Zoning permit that is a required precursor to a Building permit. The objective is to be able to view the details of that Zoning permit from within the Building Screen. I created a script that will browse select fields of the Zoning record from within the Building Screen. This script uses "Building" as the Module, "Building" as the Screen and "Left" as the Action which means it will run when you click on the User Script Button in the Building Screen.

mylink = strextract(build1.notes1,"<BeginLink>","<EndLink>",1,1)
if not empty(mylink) select id_code as id,typeinsp as type,details,cert as permit,cert_date as date from zoning
into cursor tempzoning where id_code = mylink
browse normal in window mainzone noedit nodelete title "Linked Zoning Record"
use in iif(used('zoning'),'zoning',0)
use in iif(used('tempzoning'),'tempzoning',0)
endif
select build1

This script will now display a browse window anytime a Zoning record is linked to a Building record, but you have to define that link. To create a link to the desired Zoning permit in the Notes1 field of the Building record I’m using the technique that is explained in the "Selective Notes Printing 1" video on the Training Videos  section of our web page.

Here are the steps I take:
- Go to the Zoning permit record that you want to link and make a note of the ID Code. (That is the second number in the ID string at the top right of the Main tab.)
- Go to the Building record where you want to implement the link.
- Go to the Notes tab. Hit "Edit", and add this text anywhere in the Notes1 field:

<BeginLink> id_code <EndLink>

- Replace the bit that says id_code with the Zoning id_code you made a note of and save your change.

Now you click on the User Script Button to display a browse table with details about the linked Zoning record. This script technique can be expanded to work with any databases. The link tags are good candidates for using with the Notekeeper feature.

To use this option with ZP SQL the initial script needs some minor changes:

mylink = strextract(build1.notes1,"<BeginLink>","<EndLink>",1,1)
if not empty(mylink)
myCommand=[select id_code as id,typeinsp as type,details,cert as permit,;
cert_date as date from zoning where id_code = '] + mylink +[']
dosqlcommand(myCommand,'tempzoning')
browse normal in window mainzone noedit nodelete title "Linked Zoning Record"
use in iif(used('tempzoning'),'tempzoning',0)
endif
select build1