Event Types
Based on the types of event, you can link the events either with the program or with the widget.
Following table lists the events that can be linked to a program, along with the description when these events are run.
Events | Description | Used as |
PROGRAM-INIT | This event is run before the program is started. |
procedure p-program-init: /*------------------------------- Event : PROGRAM-INIT --------------------------------*/ Description : Set session variable in init of program --------------------------------*/ /* reset the session values */ f-set-xsest('openDate',today) end procedure. /* p-program-init */ |
AFTER-CREATEQUERY | After the main query of the maintenance program has been created. |
procedure p-afterCreateQuery: /*---------------------------------- Event : AFTER-CREATEQUERY ------------------------------*/ find xprog where rowid(xprog) = vrowidxprog no-lock. assign v-prepare = 'for each xwfields where xwfields.xproc = ' + quoter(xprog.xproc) + ' no-lock' p-result = v-prepare . end procedure. /* p-afterCreateQuery */ |
AFTER-DELETE | After record has been deleted from database |
procedure p-after-delete: /*----------------------------------- Event : AFTER-DELETE ----------------------------------*/ Description :-After deleting the SR from the x/xsremsr.p page refresh the parent program that is x/xsrem.p otherwise the SR is visible on the screen unless the refresh button is clicked. Display the Next SR Detail after the Current SR is deleted. ---------------------------------*/ defvar v-parent ashandleno-undo. v-parent = handle (f-get-xsest ('parentprog')). /* get the handle of the parent program(x/xsrem.p) */ if valid-handle(v-parent) then do: run p-currentprog in v-parent (output v- handle). run s-refresh in v-handle. end. /*Display the Next SR Detail based on the query on the first tab program */ p-action = 's-prev-page' + chr (1) + 's-next-page'. endprocedure. /* p-after-delete */ |
BEFORE-COMMIT | Before the record is actually committed when the Commit button is clicked |
procedure p-before-commit: /*---------------------------------Event : Before-Commit --------------------------------- Description : Validation of prtno ---------------------------------*/ define variable v-prtno as characterno-undo. assign v-prtno = f-getvalue('prtno'). /* begin:***** Part validations ****** */ if v-prtno = ''then do: p-error = 'prtno-must'. return. end. /* Validate part number, must not exist in DB */ if can-find (first prt where prt.prtno = v-prtno) then do: p-error = 'duppart' + chr(1) + v-prtno. return. end. endprocedure. /* p-before-commit */ |
Before-commit2 | After commit button is clicked and before committing the records |
procedure p-beforecommit2: /*------------------------------- Event : BEFORE-COMMIT2 ------------------------------ Description : it takes the output from previous program and if the feedback is negative, then calcel the task. ----------------------------------*/ /*checks the user previous output and performs the task accordingly*/ if(f-getvalue('answer')='FALSE') then p-action = 's-cancel'. endprocedure. /* p-beforecommit2 */ |
AFTER-COMMIT | After records has been committed to database |
procedure p-after-commit: /*-------------------------------- Event : AFTER-COMMIT ------------------------------------- Description : get max 'rshno' which is stored as counter in table 'num' as per different company code ----------------------------*/ if p-mode = 3then/* Update Mode */ do: /* Update the Quoted currency code if different */ find rsh whererowid(rsh) = p-rowid exclusive-lockno-error. /* find the rsh being updated */ if avail rsh and rsh.curcdQuot<>''then do: assign rsh.curcdQuot = rsh.curcd . releasersh. end. end. /* Update Mode */ endprocedure. /* p-after-commit */ |
BEFORE-DELETE | Before the record is actually deleted from the DB when the Delete button is clicked |
Procedure p-before-delete: /*----------------------------------- File : xpdoc (Project Documents)Field :Event : BEFORE-DELETE ------------------------------------- Description : Sets document status to 'Deleted'. This includes all versions of a document. ----------------------------------*/ define var v-xpdon like xpdoc.xpdon no-undo. define var v-xpdonversion like xpdoc .xpdonversion no-undo. find first xpdoc where rowid(xpdoc)= p-rowid no-lockno-error. if avail xpdoc then assign v-xpdon = xpdoc.xpdon. /* changes status of all versions of the selected document to 'deleted' */ for each xpdoc where xpdoc.xpdon = v-xpdon exclusive-lock: assign xpdoc.xstac = "3000". end. release xpdoc. p-action = "s-qryreopen". endprocedure. |
BEFORE -DISPLAY | Before the record is displayed in the maintenance program. |
procedure p-beforeDisplay: /*----------------------------------- Event : BEFORE-DISPLAY -----------------------------------*/ /* Displays the customer discount in screen */ find first customer whererowid (customer) = p-rowid no-lockno-error. if available customer then do: p-result = 'v-discount' + chr(1) + string(customer.discount). end. endprocedure. /* p-beforeDisplay */ |
AFTER-DISPLAY | After the record has been displayed in the maintenance program |
Event : AFTER-DISPLAY ----------------------------------*/ procedure p-after-display:/* ------------------------------------- def variable v-item-num asintno-undo .defvariable v-img-path ascharno-undoinit"item/". v-item-num = integer(f-getvalue('item-num')). v-img-path = v-img-path + string(v-item-num) + '.jpg'. /* Prepare image name and display in screen */ p-attribute = p-attribute + min (p-attribute, chr(1)) + 'v-itm-image' + chr(1) + 'load-image()'+ chr(1) +v-img-path + chr(1) + 'v-itm-image' + chr(1) + 'stretch-to-fit' + chr(1) + 'false' + chr(1) + 'v-itm-image'+ chr(1) + 'transparent' + chr(1) + 'false'. endprocedure. /* p-afterDisplay */ |
BEFORE-ENABLE | After New/Copy/Update button is clicked and right before the widgets are enabled. |
procedure p-before-enable: /*----------------------------------- Event : BEFORE-ENABLE ------------------------------------- Description : ----------------------------------*/ /* is error is set in sesson then show error message and return */ if logical(f-get-xsest('is-error')) then p-error = 'adcRfqMailSu'. endprocedure. /* p-before-enable */
|
AFTER-ENABLE | After New/Copy/Update button is clicked and all the widgets have been enabled. |
procedure p-afterenable: /*--------------------------------- Event : AFTER-ENABLE ----------------------------------*/ find coline where rowid(coline) = p-rowid. if f-getvalue("colitStatus") = 'ship'then p-attribute = "colitStatus" + chr(1) + "Sensitive" + chr(1) + "false" .endprocedure. /* p-afterenable */ |
BEFORE-FILTER | Runs when the Custom Filter program is committed. It is used to change the program query based on the filter parameters of the custom filter program. |
procedure p-preparequery: /*----------------------------------- Event : BEFORE-FILTER -------------------------------------*/ /*variables to store query */ definevariable v-querystring ascharacterno-undo.definevariable v-tordn_cond ascharacterno-undo. definevariable v-ccusn_cond ascharacteno-undo. /*prepares query*/v-querystring = 'for each corder where corder.xlevc = [xlevc]~n'+ '[v-tordn_cond]~n'+ ' [v-ccusn_cond] no-lock'. /*checks the widget value of customer no and assigns the values to variables accordingly*/ if f-getvalue('v-ccusn') >'0'then v-ccusn_cond = " and corder.ccusn = " + f-getvalue('v-ccusn'). else v-ccusn_cond = ''. if f-getvalue('t-cordn') >'0'then v-tordn_cond = " and corder.cordn LE " + f-getvalue('t-cordn'). else v-tordn_cond = ''. assign v-querystring = replace (v-querystring, '[xlevc]', quoter (f-xlevc('corder'))) v-querystring = replace (v-querystring, '[v-tordn_cond]', v-tordn_cond) v-querystring = replace (v-querystring, '[v-ccusn_cond]', v-ccusn_cond). p-result = v-querystring. endprocedure. /* p-preparequery */ |
BEFORE-NEW | After New/Copy button is clicked and right before the widgets are enabled. |
procedure p-before-new: /*Display error is the program name already exist in table*/ if can-find(first xprog where xprog.xproc = f-getvalue("xproc")) then do: p-error = "recordexists". return. end. endprocedure. |
BEFORE-LOGIN | Runs before logging the users in application for validations and other work |
Event : BEFORE-LOGIN if f-getvalue('username') = '' or f-getvalue('username') = ? then do: p-error = 'AD-Userempty'. return. end. endprocedure. /* p-beforelogin */ |
COMMIT-COMPLETE | This event runs when a record is committed physically. |
procedure p-commit-complete: assign p-attribute = p-attribute + min (p-attribute,chr(1)) + 'v-download' + chr(1) + 'sensitive'+ chr(1) + 'true' + chr(1) + 'v-btnfileopen' + chr(1) + 'sensitive'+ chr(1) + 'true'. p-action = 's-refresh' . end procedure. /* p-commit-complete */ |
PROGRAM-PRE-START | Runs before program start event, could be used with custom filter to set filter widget values. | Used for XEML which is not used anymore. |
PROGRAM-START | While a program is started. |
/*--------------------------------- Event : PROGRAM-START -----------------------------------*/ /* display the session values in respective widgets */p-result = 'v-partNo' + chr(1) + f-get-xsest('prt_no'). /* reset the session varlues */ f-set-xsest('prt_no',''). end procedure. /* p-programStart */ |
PROGRAM-STOP | When a program is stopped. |
procedure p-xe-logout: /*-------------------------------- Event : PROGRAM-STOP ------------------------------- Description : this is the event on logout , deletes session data ------------------------------------*/ define variable v-isduplicate as character no-undo. define variable v-xsesc as character no-undo. run p-returnvar in v-xe-sourceprocedure (input"v-isduplicate",output v-isduplicate). if not logical(v-isduplicate) then do transaction: /* Shree v6.309 Find current xpse record */ find xpsession where xpsession.xpsen = int(f-getvalue("xpsen")) no-lock no-error. if available xpsession then do: v-xsesc = xpsession.xsesc. for each xpsession where xpsession.xsesc = v-xsesc exclusive-lock: for each xpsbrowse of xpsession exclusive-lock: delete xpsbrowse. end. for each xpsquery of xpsession exclusive-lock: delete xpsquery. end. for each xpsfilter of xpsession exclusive-lock: delete xpsfilter. end. delete xpsession. end. end. end. end procedure. /* p-xe-logout */ |
TAB-COMPLETE | At the end of tab-display. |
procedure p-tab-complete: /*----------------------------- Event : TAB-COMPLETE -------------------------------- Description : -------------------------------*/ find xuser where xuser.xusec = f-xusec() no-lock no-error. p-result = p-result + min(p-result,chr(1)) + "xusec" + chr(1) + xuser.xusec + chr(1) + "v-xusem"+ chr(1) + xuser.xusem. end procedure. /* p-after-display */ |
TAB-HIDE | When you switch to another tab-program, the tab-program that is going to hide fires this event. |
procedure p-tab-hide: /*----------------------------------- Event : TAB-HIDE ------------------------------------- Description : Deleted thumbnail files from 'Local Temp' directory defined in System defaults ----------------------------------*/ run p-delete-thumbnail. /* delete thumbnail from local system */ end procedure. /* p-tab-hide */ |
TAB-SHOW | When you switch to another tab-program, the tab-program that is going to open fires this event. |
procedure p-tab-show: /*------------------------- Event : TAB-SHOW ---------------------------------------- Description : Create the project specific sequence in table xseq -----------------------------------------*/ define variable v-seqc as character no-undo. find xprecord where rowid(xprecord) = f-getrowid ('xprecord') no-lockno-error.v-seqc = 'pst' + xprecord.xprec + 'r'.ifnotcan-find (firstxseqwherexseq .xlevc = '1'and xseq.xseqc = v-seqc no-lock) then do: createxseq. assign xseq.xseqn = 1 xseq.xseqm = xprecord.xprec + " Risk sequence" xseq.xseqc = v-seqc xseq.xlevc = "1" xseq.xseqlreserved = yes. end. endprocedure. /* p-tab-show */ |
TT-FILLQUERY | This event is used for filling the temp tables in programs using XE- temp tables. |
procedure p-fillquery: /*----------------------------------- Event : TT-FILLQUERY -------------------------------------*/ define variable v-prep as character no-undo. define variable v-fields as character no-undo. define variable v-hquery as handle no-undo. define variable v-buffer as handle no-undo. p-tt:default-buffer-handle:empty-temp-table. for each _UserTableStat no-lock: create tt-usertablestat. assign tt-usertablestat.t-conn = _UserTableStat. _UserTableStat-Conn tt-usertablestat.t-create = _UserTableStat. _UserTableStat-create. end. createquery v-hquery. v-hquery:set-buffers(buffer tt-usertablestat:handle). v-prep = "FOR EACH tt-usertablestat". v-prep = v-prep + ".". v-hquery:query-prepare(v-prep). v-hquery:query-open(). repeat: v-hquery:get-next. if v-hquery:query-off-endthen leave. v-buffer = v-hquery:get-buffer-handle(v-hquery: num-buffers). p-tt:default-buffer-handle:buffer-create. /* assign value to buffer */ p-tt:default-buffer-handle:buffer-copy (v-buffer,?, "t-conn," + "t-conn"). p-tt:default-buffer-handle:buffer-copy (v-buffer,?, "t-create," + "t-create"). end. /* repeat */ v-hquery:query-close(). p-action = "s-refresh". endprocedure. /* p-fillquery */ |
DYNAMIC-CHOOSE | When a dynamically created button is clicked. You can only use a single event procedure for all the dynamically created buttons in a program. Dynamic buttons can be created using the action NEWWIDGET. |
procedure p-dynamicChoose: /*------------------------------------------- Event : DYNAMIC-CHOOSE ---------------------------------------------*/ define variable vtarget as characterno-undo. define variable v-partWidget as character no-undo. /* get the button name which has been clicked */ vtarget = dynamic-function('f-findnode'in v-xe-sourceprocedure, 'targetWidget'). /* logic to run if only v-rfqButton is clicked */ if index(vtarget,'.v-rfqButtonBackEnd') > 0 then do: /* get the button name , always in the format .v-rfqButton-ttRequested-0-ttParts-0 where '-0' may be different base on location of data in dataset */ assign v-partWidget = replace(vtarget,' .v-rfqButtonBackEnd', 'prtno') /* dynamically generate widget of part number based on button clicked */. /* put partno , quantity , and description in session variables which are to be filled in r/rchem.p maintenance program */ f-set-xsest('prt_no',f-getvalue (v-partWidget)). /* run Quote creating maintenance program */ p-action = 'runxeprog' + chr(2) + 'r/rchem.p'. end. /* if rfqbutton clicked */ end. |
DYNAMIC-CHOOSE2 | Choose event of dynamic buttons in frontend (js) |
var fContinueShop = function(){ /*--------------------------------- Field: v-continueShoppingEvent : DYNAMIC-CHOOSE-2 ----------------------------------*/ var targetWidget = x.getNodeValue ('targetWidget'); if (targetWidget.indexOf('v-continueShopping') >= 0) {var o = x.getCurrentScreen ();var eId = o.properties.id + '-' + 'v-continueShoppingFrmJs'; var pId = o.properties.id + '-' + 'v-continueShopping'; var $button = $(_.find(o.properties .elem.$eCache, function (o) { return o.id === eId; })); var $button1 = $(_.find(o.properties. elem.$eCache, function (o) { return o.id === pId; })); //Disable search button and click hidden search button to call backend event $button1.attr('disabled','disabled'); $button.trigger('click', 'eventData'); }}; /* fContinueShop */ |
ON-MSGBROADCAST | WebSocket implementation in HTML5. This event only works when the deployment is in AppInterface Servlet. Message is broadcasted by a program to any number users using the same program. Message broadcast is done at record navigation and record update level which can be configured per program. | Backend reserved. |
ON-RETURN | When the user presses the Return/Enter key while the focus is in an enabled widget which is not a search field. This event only works in display mode. |
procedure p-onReturn: /* On click of enter button, execute p-searchOrder procedure */run p-searchOrder .endprocedure. /* p-onReturn */ |
TT-BeforeQuery | Used to fill temp table for temp table maintenance program |
procedure p-filltemptable: /*--------------------------- Event : TT-BEFOREQUERY ----------------------------- Description : procedure to fill temp table -------------------------------*/ /*variable to store benefit of employee*/ definevariable v-benefits ascharacterno -undoformat"x(200)". /*list all the employee ordered by department*/ foreach eemployee no-lockby eemployee.edepc descending: /*makes the list of benefits enjoyed by employee*/ foreach ebenefits where ebenefits.xlevc = f-xlevc("ebenefits") and ebenefits.eempn = eemployee.eempn: do: if ebenefits.ebentHealthCare <>''then v-benefits = "Health care :" + string (ebenefits.ebentHealthCare). end. /*do statements*/ end. /*for each ebenefits*/ create tt-eemployee. assign tt-eemployee.eempn = eemployee.eempn tt-eemployee.eempfirstname = eemployee .eempcFirstName tt-eemployee.eemplastname = eemployee .eempcLastName tt-eemployee.covonbenefit = v-benefits. /*reset counter and benefits variable*/ v-benefits = ''. end. /*for each employee*/ p-tt = temp-table tt-eemployee:handle. p-action = 's-qryreopen'. endprocedure. /* p-filltemptable */ |
COMMIT-COMPLETE | This event runs when a record is committed physically |
procedure p-commit-complete:assign p-attribute = p-attribute + min(p-attribute,chr(1)) + 'v-download' + chr(1) + 'sensitive'+ chr(1) + 'true' + chr(1) + 'v-btnfileopen' + chr(1) + 'sensitive'+ chr(1) + 'true'.p-action = 's-refresh' .endprocedure. /* p-commit-complete */ |
After-CreateQuery | After the main query of main maintenance program has been created |
procedure p-afterCreateQuery: /*--------------------------- Event : AFTER-CREATEQUERY ----------------------------- Description : -------------------------------*/ find xprog where rowid(xprog) = vrowidxprog no-lock.assign v-prepare = 'for each xwfields where xwfields.xproc = ' + quoter(xprog.xproc) + ' no-lock'p-result = v-prepare.endprocedure. /* p-afterCreateQuery */ |
DS-FILL: | For displaying records intemp-table maintenance program using data set |
procedure p-dsfill: /*------------------------------ Event : DS-FILL -------------------------------*/ for each arh no-lock:create tt-arh .buffer-copy arh to tt-arh no-error.dataset arhds:write-json('longchar',p-dataset). end. endprocedure. /* p-dsfill */ |
DS-ROW-CREATE | Runs when new record is created in data set | Used As: procedure p-ds-row-create-arh-tt: /*—————————— Event : DS-ROW-CREATE ——————————*/ def variable v-jsondata as longchar no-undo.def variable v-accnum as integer no-undo.v-accnum = integer(f-getvalue(‘anum’)).run p-getDatasetJson in v-xe-sourceprocedure(input0,output v-jsondata). dataset arhds:read-json (‘longchar’,v-jsondata).findfirst tt-arh where tt-arh.anum = v-accnum no-lockno-error. ifavail tt-arh then |
DS-ROW-DELETE | Runs when records is deleted in data set |
procedure p-row-delete-ds: /*-------------------------------- Event : DS-ROW-DELETE ----------------------------------*/ def var jsonData as longchar no-undo. def var v-xuseladmin as log no-undo. assignv-xuseladmin = logical(f-getvalue ('xuseladmin')) no-error. if v-xuseladmin then do: p-error = 'xe-norights'. end. endprocedure. /* p-row-delete-ds * |
DS-ROW-UPDATE | Runs when records is updated in data set |
procedure p-row-update-ds: /*------------------------ Event : DS-ROW-UPDATE -----------------------*/ run p-addresult in v-xe-sourceprocedure (input0, input ?, input'xuserremote', input'xlprc',input'default'). /* change buffer field */ endprocedure. /* p-row-update-ds */ |
DS-AFTER-DELETE | Runs after records deleted from data set |
procedure p-after-delete-arh-tt: /*------------------------------ Event : DS-AFTER-DELETE ---------------------------------*/ def variable v-jsondata as longchar no-undo. def variable v-accnum asintegerno-undo. v-accnum = integer(f-getvalue('anum')). run p-getDatasetJson in v-xe-sourceprocedure (input0,output v-jsondata). dataset arhds:read-json ('longchar', v-jsondata). for each arh exclusive-lock: find first tt-arh where tt-arh.anum = arh.anum no-lock no-error. if not avail tt-arh then delete arh. end. release arh. endprocedure. /* p-after-delete-arh-tt */ |
DS-AFTER-COMMIT | Runs after records committed in data set |
procedure p-after-commit-arh-tt: /*----------------------------------- Event : DS-AFTER-COMMIT ------------------------------------*/ def variable v-jsondata as longchar no-undo. def variable v-accnum as integer no-undo. v-accnum = integer(f-getvalue('anum')). run p-getDatasetJson in v-xe-sourceprocedure (input0,output v-jsondata). dataset arhds:read-json ('longchar', v-jsondata). find first tt-arh where tt-arh.anum = v-accnum no-lock no-error. if avail tt-arh then do: /* Server part to save new data or to update data */ find first arh where arh.anum = tt-arh.anum exclusive-lock no-error. if not avail arh then create arh. buffer-copy tt-arh to arh. /* Set field value for both update and new */ if error-status:error then p-error = "Error occured". end. endprocedure. /* p-after-commit-arh-tt */ |
Events could also be related with the widget. Different actions on the widget fires different X/E events. Following table lists events related to a Widget:
Events | Occurrence | Used as |
CHOOSE | This event runs when a button type widget is clicked. |
procedure p-openProg-btn: /*-------------------------------- Field: v-openProg-btn Event : CHOOSE ----------------------------------*/ /* Open user maintenance program on click of button */ p-action = 'runxeprog' + chr(2) + 'x/xusem.p'. endprocedure. |
LEAVE | When the focus is removed from the widget. |
procedure p-orderdate: /*-------------------------- File : corder (corder) Field: corddOrder Event : LEAVE ------------------------------*/ /*checks the screen value of widget*/ ifdate(p-value) >todaythen /*prints errror if the date entered is greater than today's date*/ p-error = "e-date" + CHR(1) + STRING(p-value) + CHR(1) + STRING(today). endprocedure. /* p-orderdate */ |
ROW-DISPLAY | Browse specific event. Could be used to display additional information in the browse which does not come from database directly (eg. fill local variable value). |
procedure p-rowdisplay: /*---------------------------------- File : corder (corder) Field: v-browse01 Event : ROW-DISPLAY ---------------------------*/ /*local variable to store total price and extended price*/ define variable v-total as decimal no-undo. define variable v-extended as decimal no-undo. find corder where ROWID(corder) = p-rowid no-lock no-error. for each coline where coline.cordn = corder.cordn: /*calculate total amount and extended amount*/ v-total = v-total + coline.colinqty * coline.siteaprice. v-extended = v-extended + ((coline.colinqty * coline.siteaprice) - (coline.colinqty * coline.siteaprice * coline.colindiscount * 0.01)). end. /*for each*/ /*to fill the data in browser*/ find corder whereROWID (corder) = p-rowid no-lockno-error. /*fills data to browser*/ ifavail corder then p-result = p-result + min(chr(1),p-result) + "v-torderprice" + CHR(1) + STRING(v-total) + CHR(1) + "v-textendedprice" + CHR(1) + STRING(v-extended). endprocedure. /* p-rowdisplay */ |
VALUE-CHANGED | When the screen-value of a widget changes. |
procedure p-customername: define variable v-customername as character no-undo. v-customername = string(f-getvalue('v-ccusm')). /* Displayes the changed ccusm field value in custname field */ p-result = p-result + min(p-result,chr(1)) + "v-custname" + chr(1) + v-customername. endprocedure. /* p-customername */ |