I had a customer ask if there was a way to have the auto numbering feature for permits increment by 10 instead of just one. You can do this by adding a script to the "Add" function of any screen. This script uses "Building" as the Module, "Building" as the Screen,
and "Add" as the Action. The script is:
newcert = left(cert, len(trim(cert))-4) +padl(alltrim(str(val(right(trim(cert),4))+9)),4,"0")
replace cert with newcert
This script add an extra 9 to the auto generated new permit number to make it increment by a total of ten. This script will work for any of the permit screens in either ZP 32 or ZP SQL.
Showing posts with label numbering. Show all posts
Showing posts with label numbering. Show all posts
3/03/2010
Preventing Permit Number Alterations
A customer contacted me who was frustrated with employees who kept screwing up ZonePro's auto numbering feature for permit numbers by manually changing the suggested numbers to their own liking. This example prevents anyone from altering the permit numbers that ZonePro assigns to each new permit. This script uses "Zoning" as the Module, "Zoning" as the Screen, and "Screen" as the Action. The script is:
znscreen.zp_pageframe1.page1.txtcert.readonly = .T.
If you use a script like this and have the year as part of your permit numbering scheme, you'll have to disable the script at the start of each year in order to switchover to the new year.
znscreen.zp_pageframe1.page1.txtcert.readonly = .T.
If you use a script like this and have the year as part of your permit numbering scheme, you'll have to disable the script at the start of each year in order to switchover to the new year.
Auto Number License Field in ZP32
In the previous post I showed how to auto number the License field in the Contractor screen with a script. That script was for ZP SQL. Some time earlier I had written a script for a customer who wanted to do the same thing in ZP 32. Their number scheme for the License field looks like this: "2010-0001". Again this script uses the User Script button and only works when you are editing. As before, this scripts uses "Contractor" as the Module, "Contractor" as the Screen, and "Left" as the Action. Here is the script:
IF CONTRACT.BROWSE_BTN.ENABLED = .F.
SELECT MAX(LICENSE) FROM CONTRACT INTO ARRAY MYLAST
MYPREFIX = STR(YEAR(DATE()),4)+"-"
MYNEWID = VAL(SUBSTR(MYLAST(1),6))+1
REPLACE LICENSE WITH MYPREFIX +
PADL(ALLTRIM(STR(MYNEWID)),4,"0")
CONTRACT.ZP_PAGEFRAME1.PAGE1.TXTLICENSE.REFRESH
ENDIF
IF CONTRACT.BROWSE_BTN.ENABLED = .F.
SELECT MAX(LICENSE) FROM CONTRACT INTO ARRAY MYLAST
MYPREFIX = STR(YEAR(DATE()),4)+"-"
MYNEWID = VAL(SUBSTR(MYLAST(1),6))+1
REPLACE LICENSE WITH MYPREFIX +
PADL(ALLTRIM(STR(MYNEWID)),4,"0")
CONTRACT.ZP_PAGEFRAME1.PAGE1.TXTLICENSE.REFRESH
ENDIF
Auto Numbering License in Contractor Screen
Yesterday I talked to a ZP SQL customer about automatically bumping up the number in the License field of the Contractor Screen in a fashion similar to Permit Number fields. I had already covered this topic for ZP 32 but the code is slightly different for ZP SQL. In this case the customer uses a numbering scheme like "C10-001" where 10 represents 2010. The script I created used the User Script button. While editing, clicking on the User Script button automatically fills in the next higher number in the License field. This scripts uses "Contractor" as the Module, "Contractor" as the Screen, and "Left" as the Action. Here is the script:
IF contscreen.isediting = .T.
myCommand = [SELECT MAX(license) AS maxnum FROM contract]
DoSqlCommand(myCommand,'myLicense')
myLast = VAL(RIGHT(TRIM(myLicense.maxnum),3))+1
myNext = LEFT(myLicense.maxnum,4)+PADL(ALLTRIM(STR(MYLast)),3,"0")
USE IN IIF(USED('myLicense'),'myLicense',0)
SELECT contract
REPLACE license WITH myNext
contscreen.ZP_PAGEFRAME1.PAGE1.TXTLICENSE.REFRESH
ENDIF
IF contscreen.isediting = .T.
myCommand = [SELECT MAX(license) AS maxnum FROM contract]
DoSqlCommand(myCommand,'myLicense')
myLast = VAL(RIGHT(TRIM(myLicense.maxnum),3))+1
myNext = LEFT(myLicense.maxnum,4)+PADL(ALLTRIM(STR(MYLast)),3,"0")
USE IN IIF(USED('myLicense'),'myLicense',0)
SELECT contract
REPLACE license WITH myNext
contscreen.ZP_PAGEFRAME1.PAGE1.TXTLICENSE.REFRESH
ENDIF
Subscribe to:
Comments (Atom)