2/02/2011

Selecting Any Contact As Applicant (ZP SQL)

A ZP SQL customer just requested an option that would allow them to select any name linked to the Property as an Applicant. In this case they were working in the Planning screen. I devised a script using the left-click Script button that brings up a browse screen showing all Contact names. When the user selects one, that name is automatically copied into the Applicant fields. Notice that the customer also wanted to copy additional Contact information into the User fields. This script only runs when you are editing a record. The script uses "Planning" for the Module, "Planing" for the Screen, and "Left" for the Action:

if planscreen.isediting
select planning
mycommand = [select rtrim(firstname)+' '+rtrim(lastname) as name,;
rtrim(st_nr)+' '+rtrim(street)+' '+rtrim(st_extra) as address1,;
address2,phone1,phone2,email,cftype from vcfsolorep where prop_id = ']+ prop_id +[']
dosqlcommand(mycommand,'mynames')
select mynames
on key label spacebar keyboard chr(23)
on key label rightmouse keyboard chr(23)
on key label enter keyboard chr(23)
browse normal in window mainzone noedit;
title "Select applicant name..."
on key label spacebar
on key label rightmouse
on key label enter
replace planning.app_type with mynames.cftype,;
planning.app_name with mynames.name,;
planning.app_phone with mynames.phone1,;
planning.app_addr1 with mynames.address1,;
planning.app_addr2 with mynames.address2,;
planning.user1 with mynames.phone2,;
planning.user3 with mynames.email
use in iif(used('mynames'),'mynames',0)
select planning
planscreen.refresh
endif