FUNCTION CUSTOMER_O4W_COMMUTER_MODULE(CtlEntId, Event, Request) * Auto-generated by O4W_DEFINE_FORM at 10:51:51 06 JAN 2010 * Standard equates $Insert O4WEquates $Insert O4WFormEquates $Insert O4W_COMMUTER_COMMON rtnValue = 1 Begin Case Case event _eqc 'PRE_READ' * called before reading record from table * variable 'ctlentid' is ID of record * variable '@record' is the record contents (if available) * variable 'userFields@' contains the values of the user-defined fields (if available) * examine variable bIsNew@ to determine if this is a new record, or a record that is supposed to exist * set variable 'rtnValue' to 0 (rtnValue=0)to disable further event processing * set variable 'rtnValue' to -1 (rtnValue=-1) to skip READ but continue processing * (If performing the read in this code, and you intend to set the rtnValue=-1, you should: * - fill the @RECORD variable with the desired record contents * - fill the userFields@ variable with the desired values for the user-defined fields * ) * set variable 'statMsg@' to desired error/status text if bIsNew@ <> "1" then * Not a new record - find out its creation date createDate = xlate("CUSTOMER", @ID, 27, "X") If createDate = DATE() Then rtnValue = 0 statMsg@ = "Invalid record requested; not yet posted" End End Case event _eqc 'READ_CHECK' * called before write or delete to verify record has not been changed by another user * set variable 'rtnValue' to -1 (rtnValue=-1) to skip READ but continue processing * (If performing the read in this code, and you intend to set the rtnValue=-1, you should fill the * @RECORD variable with the desired record contents) Case event _eqc 'POST_WRITE' * called after writing record to table * variable 'ctlentid' is ID of record * variable '@record' is the record contents (if available) * variable 'userFields@' contains the values of the user-defined fields (if available) * set variable 'statMsg@' to any desired 'success' message * set variable 'redirectTo@' to url to transfer to after success redirectTo@ = "http:%%//%%www.revelation.com" statMsg@ = "Thank you for updating this record! You will now be redirected to the Revelation Home Page..." Case event _eqc 'TAB' * called when 'tab' clicked, or back/next button clicked * variable 'ctlentid' is number of current tab tabname = formDef@ * variable userFields@ is number of 'next' tab * set variable 'rtnValue' to 0 (rtnValue=0) to abort tab change * set variable 'statMsg@' to any desired error/status text * to examine all the fields on the current tab: num.fields = dcount(formDef@, @VM) for each.field = 1 to num.fields if formDef@ = tabname then fieldName = formDef@ thisValue = O4WGetValue('FIELD_':each.field) end next each.field Case Event _eqc 'PRE_FIELD' * called when specified field has gotten 'focus' fieldName = O4WCommuterUtility(CtlEntId, O4WUTILITY_FIELDNAME$) Begin Case Case fieldName _eqc 'WEBSITE' End Case Case Event _eqc 'POST_FIELD' * called when specified field has 'lost focus' fieldName = O4WCommuterUtility(CtlEntId, O4WUTILITY_FIELDNAME$) currValue = O4WCommuterUtility(CtlEntId, O4WUTILITY_VALUE$) Begin Case Case fieldName _eqc 'WEBSITE' Case fieldName _eqc 'ADDRESS1' * Change the 'address2' list box Call findSubAddress(currValue, DESCS, CODES) add2Control = O4WCommuterUtility(CtlEntId, O4WUTILITY_FORMELEMENT_CONTROL$, "ADDRESS2") add2Section = O4WCommuterUtility(CtlEntId, O4WUTILITY_FORMELEMENT_CONTROL_SECTION$, "ADDRESS2") o4wSectionStart(add2Section, O4WResponseStyle()) O4WListbox(DESCS, CODES, add2Control) O4WSectionEnd(add2Section) Case fieldName _eqc 'CITY' Call FindStateFromCity(currValue, ourState) * Determine the web form's "input element" name for the STATE field stField = O4WCommuterUtility(CtlEntId, O4WUTILITY_FORMELEMENT_CONTROL$, "STATE") O4WUpdate(stField, ourState, O4WResponseStyle(%%''%%,'1')) End Case Case Event _eqc 'CLICK' * called when user-defined or 'dummy' popup button clicked fieldName = O4WCommuterUtility(CtlEntId, O4WUTILITY_FIELDNAME$) clickType = O4WCommuterUtility(CtlEntId, O4WUTILITY_CONTROLTYPE$) Begin Case Case fieldName _eqc 'GROUP' * called from clicking 'popup' button Case fieldName _eqc 'SampleBtn' * called from clicking user-defined button O4WError("This button intentionally left blank") End Case End Case Return rtnValue