Goal: quickly locate the right WfForm API by scenario. This version keeps API names, constants, config keys, and important constraints, while removing screenshots, long demos, and repeated explanations.
Basic Rules
#- Global object:
window.WfForm; most code uses WfForm directly. - Mobile check:
WfForm.isMobile(); backend code can read _ec_ismobile. - Frontend entry points: template code blocks, route-level custom pages, and app-level global custom pages.
- Do not import
init_wev8.js in route-level or global custom pages. - Prefer
WfForm APIs for field operations. Avoid jQuery("#field111").val() and do not mutate form fields with raw DOM APIs. - Field mark format: main fields look like
field111; detail fields look like field111_0. viewAttr: 1 read-only, 2 editable, 3 required, 4 hide field label and content, 5 hide the whole row.
Open Workflow Forms
#| Scenario | API or URL | Notes |
|---|
| PC create request | window.open('/workflow/request/CreateRequestForward.jsp?workflowid=747') | Pass workflow ID; the active version is resolved by the system. |
| PC view request | window.open('/workflow/request/ViewRequestForwardSPA.jsp?requestid=5963690') | The user must have permission to view the request. |
| Mobile recommended | window.openLink.openWorkflow(url, callbackFun, returnUrl) | Custom pages must load /spa/coms/openLink.js. |
| Mobile fallback | window.open(url + '&returnUrl=' + encodeURIComponent(returnUrl)) | Not recommended; manual-back callbacks are hard to control. |
| Mobile hover window | window.showHoverWindow(url, baseRoute) | Useful from non-main form views such as detail-row edit pages. |
Action Events
#Before-action Guards
#WfForm.registerCheckEvent(type, fn) runs before the action. The callback must call callback() to continue; otherwise the action is blocked.
| Constant | Usage |
|---|
WfForm.OPER_SAVE | Before save. |
WfForm.OPER_SUBMIT | Before submit, approve, submit-with-feedback, submit-without-feedback. |
WfForm.OPER_SUBMITCONFIRM | Before submit confirmation page; the confirm page then triggers OPER_SUBMIT. |
WfForm.OPER_REJECT | Before reject. |
WfForm.OPER_REMARK | Before remark submit. |
WfForm.OPER_INTERVENE | Before intervene. |
WfForm.OPER_FORWARD | Before forward. |
WfForm.OPER_TURNHANDLE | Before transfer. |
WfForm.OPER_TURNREAD | Before circulate/read. |
WfForm.OPER_FORCEOVER | Before forced archive. |
WfForm.OPER_TAKEBACK | Before forced take-back. |
WfForm.OPER_DELETE | Before delete. |
WfForm.OPER_ADDROW + detailIndex | Before adding a detail row; detail index starts from 1. |
WfForm.OPER_DELROW + detailIndex | Before deleting a detail row. |
WfForm.OPER_PRINTPREVIEW | Before print preview. |
WfForm.OPER_WITHDRAW | Before withdraw. |
WfForm.OPER_CLOSE | Before page close. |
WfForm.OPER_SAVECOMPLETE | After save and before page navigation. |
WfForm.OPER_ASKOPINION | Before asking for opinion. |
WfForm.OPER_TAKFROWARD | Before opinion transfer. |
WfForm.OPER_BEFORECLICKBTN | Before right-menu button click. |
WfForm.OPER_BEFOREVERIFY | Before required-field validation. |
WfForm.OPER_EDITDETAILROW | Before mobile detail-row edit. |
js
jQuery(function () {
WfForm.registerCheckEvent(WfForm.OPER_SUBMIT, function (callback) {
// Continue after custom validation.
callback();
});
});
After-action Hooks
#WfForm.registerAction(actionName, fn) runs after the action.
| Constant | Usage |
|---|
WfForm.ACTION_ADDROW + detailIndex | After adding a detail row. |
WfForm.ACTION_DELROW + detailIndex | After deleting detail rows. |
WfForm.ACTION_EDITDETAILROW + detailIndex | Mobile detail-row edit. |
WfForm.ACTION_SWITCHDETAILPAGING | Detail-table page switch. |
WfForm.ACTION_SWITCHTABLAYOUT | Template tab-layout switch. |
js
WfForm.registerAction(WfForm.ACTION_ADDROW + '1', function (index) {
console.log('new row index:', index);
});
Field APIs
#| Task | API | Key Point |
|---|
| Convert field name to mark | WfForm.convertFieldNameToId(fieldname, symbol?, prefix?) | symbol is main or detail_1; prefix=false returns only the numeric ID. |
| Read value | WfForm.getFieldValue(fieldMark) | Browser fields return selected IDs by default. |
| Read browser value object | WfForm.getFieldValueObj(fieldMark) | The source demo uses it to read specialobj; verify case and availability in target systems. |
| Write value | WfForm.changeFieldValue(fieldMark, valueInfo) | Attachments are not supported; linkage and formatting are triggered. |
| Change display state | WfForm.changeFieldAttr(fieldMark, viewAttr) | 4 hides the field; 5 hides the row. |
| Write value and state | WfForm.changeSingleField(fieldMark, valueInfo, variableInfo) | Example: write a value and make it read-only. |
| Batch write | WfForm.changeMoreField(changeDatas, changeVariable) | Update multiple field values and attributes in one call. |
| Trigger all linkage | WfForm.triggerFieldAllLinkage(fieldMark) | Includes field linkage, SQL linkage, formula, row/column rules, display rules, select linkage, and bindPropertyChange. Invalid after archive. |
| Read field config | WfForm.getFieldInfo(fieldid) | fieldid has no field prefix; returns htmltype, detailtype, fieldname, fieldlabel, viewattr. |
| Read current display state | WfForm.getFieldCurViewAttr(fieldMark) | Runtime state after display linkage, API changes, and done-state rules. |
js
const field = WfForm.convertFieldNameToId('zs');
WfForm.changeFieldValue(field, { value: 'text value' });
WfForm.changeFieldValue('field11_2', {
value: '2,3',
specialobj: [
{ id: '2', name: 'Zhang San' },
{ id: '3', name: 'Li Si' }
]
});
Field Events and Custom Rendering
#| Task | API | Key Point |
|---|
| Main-field change | WfForm.bindFieldChangeEvent(fieldMarkStr, fn) | Callback often receives obj, id, value. |
| Detail-field change | WfForm.bindDetailFieldChangeEvent(fieldMarkStr, fn) | Callback often receives id, rowIndex, value. |
| Field-area action | WfForm.bindFieldAction(type, fieldids, fn) | onfocus, onclick, and similar events are bound to the cell area, not only the input element. |
| Proxy single-line text | WfForm.proxyFieldComp(fieldMark, el, range) | Single-line text fields only; range can limit read-only/editable/required states. |
| Append render content | WfForm.afterFieldComp(fieldMark, el, range) | Adds custom content after the standard field. |
| Functional field proxy | WfForm.proxyFieldContentComp(fieldid, fn) | Higher priority than proxyFieldComp and afterFieldComp. |
| Force field render | WfForm.forceRenderField(fieldMark) | Common after proxying a field from code blocks/custom pages. |
| Generate field component | WfForm.generateFieldContentComp(fieldMark) | Used with React and mobxReact.Provider for custom layouts. |
| Read layout store | WfForm.getLayoutStore() | Used together with getGlobalStore() for custom rendering. |
js
WfForm.bindFieldChangeEvent('field27555,field27556', function (obj, id, value) {
console.log(id, value);
});
Detail-table APIs
#| Task | API | Key Point |
|---|
| Add detail row | WfForm.addDetailRow(detailMark, initAddRowData) | detailMark looks like detail_1; initial field values can be passed. |
| Delete detail row | WfForm.delDetailRow(detailMark, rowIndexMark) | rowIndexMark can be all or 3,6. |
| Check detail rows | WfForm.checkDetailRow(detailMark, rowIndexMark, needClearBeforeChecked) | Can clear previous checks before checking. |
| List all row marks | WfForm.getDetailAllRowIndexStr(detailMark) | Returns comma-separated row marks. |
| List checked row marks | WfForm.getDetailCheckedRowIndexStr(detailMark) | Returns currently checked rows. |
| Disable row checkboxes | WfForm.controlDetailRowDisableCheck(detailMark, rowIndexMark, disableCheck) | Rows disabled by backend config cannot be controlled by this API. |
| Hide/show rows | WfForm.controlDetailRowDisplay(detailMark, rowIndexMark, needHide) | UI-only hiding; row serial numbers are not recalculated. |
| Read database row key | WfForm.getDetailRowKey(fieldMark) | Existing rows only; new or missing rows return -1. |
| Count rows | WfForm.getDetailRowCount(detailMark) | Count only; do not treat it as row indexes. |
| Copy last row on add | WfForm.setDetailAddUseCopy(detailMark, needCopy) | Works on manual add after ready; attachment fields are not copied. |
| Read display serial | WfForm.getDetailRowSerailNum(mark, rowIndex) | Original API spelling is Serail. |
js
const rows = WfForm.getDetailAllRowIndexStr('detail_1');
(rows ? rows.split(',') : []).forEach(function (rowIndex) {
const value = WfForm.getFieldValue('field222_' + rowIndex);
console.log(value);
});
Global APIs
#| Task | API | Key Point |
|---|
| Read request context | WfForm.getBaseInfo() | Workflow, node, form, primary/sub account info. |
| Read global store | WfForm.getGlobalStore() | Useful for debugging right menus and custom rendering. |
| Read operation store | WfForm.getOperateStore() | Useful for locating mobile right-menu button types. |
| Message | WfForm.showMessage(msg, type, duration) | type=2 can be used for error style. |
| Confirm dialog | WfForm.showConfirm(content, okEvent, cancelEvent, otherInfo) | Mobile-compatible; PC supports title and button text. |
| Disable top/right-menu buttons | WfForm.controlBtnDisabled(isDisabled) | Can disable and restore. |
| Trigger right-menu action | WfForm.doRightBtnEvent(type) | Call only; do not override. |
| Reload form | WfForm.reloadPage(params) | Defaults to current requestid; params can override. |
| Mobile hover link | window.showHoverWindow(url, baseRoute) | Useful from detail-row edit pages. |
| Append submit params | WfForm.appendSubmitParam(obj) | Prefer a cus_ prefix to avoid overriding standard params. |
| Read first empty required field | WfForm.getFirstRequiredEmptyField() | Returns field${fieldid}_${rowIndex}. |
| Trigger required validation | WfForm.verifyFormRequired(mustAddDetail, fieldRequired) | Returns a boolean and shows validation messages. |
Field-type APIs
#| Task | API | Limit |
|---|
| Add browser data URL params | WfForm.appendBrowserDataUrlParam(fieldMark, jsonParam) | Non-date browser fields; backend browser interfaces must read URL params. |
| Read browser display names | WfForm.getBrowserShowName(fieldMark, splitChar) | Joins multiple values with the separator. |
| Remove select options | WfForm.removeSelectOption(fieldMark, optionKeys) | Select fields; comma-separated option keys. |
| Control visible select options | WfForm.controlSelectOption(fieldMark, optionKeys) | Empty string clears all options. |
| Read select display names | WfForm.getSelectShowName(fieldMark, splitChar) | Select fields. |
| Empty text placeholder | WfForm.setTextFieldEmptyShowContent(fieldMark, showContent) | Single-line text, integer, float, thousands, and non-HTML multiline fields. |
| Override browser props | WfForm.overrideBrowserProp(fieldMark, jsonParam) | Use carefully; it overwrites browser component props. |
| Control date range | WfForm.controlDateRange(fieldMark, start, end) | Date fields; start/end may be day offsets or date strings. |
| Radio print text only | WfForm.controlRadioPrintText(fieldid) | Radio-style select fields in print scenarios. |
js
WfForm.appendBrowserDataUrlParam('field111', { cus_type: 'A' });
WfForm.controlDateRange('field222_0', '2019-05-01', '2019-05-31');
Sign Remark APIs#
| Task | API | Key Point |
|---|
| Read sign remark | WfForm.getSignRemark() | Returns current sign remark content. |
| Set sign remark | WfForm.setSignRemark(text, isClear=true, isAfter=true, callback) | Can overwrite, prepend, or append. |
| Extend bottom bar | WfForm.appendSignEditorBottomBar(comps=[]) | Adds custom React components or elements. |
Legacy E8 Compatibility
#| Legacy API | Recommended Replacement | Notes |
|---|
window.checkCustomize = function () {} | WfForm.registerCheckEvent(...) | Return true to continue, false to block; avoid in new code. |
jQuery('#field27563').bindPropertyChange(...) | WfForm.bindFieldChangeEvent(...) | Legacy version depends on DOM. |
_customAddFun${groupid}(addIndexStr) | WfForm.registerAction(WfForm.ACTION_ADDROW + detailIndex, ...) | groupid starts from 0; action constants are appended with detail index from 1. |
_customDelFun${groupid}() | WfForm.registerAction(WfForm.ACTION_DELROW + detailIndex, ...) | Compatibility only. |
window._writeBackData / _writeBackData | WfForm.changeFieldValue(...) | Use the API for browser-field writes in new code. |
Raw document.getElementById(...).value | WfForm field APIs | Raw DOM mutations are upgrade-risky. |
Common System Config
#These settings usually affect all workflow forms in the current Ecology system. Confirm scope before changing them.
| Goal | Config or Endpoint | Values |
|---|
| Default sign font | /api/workflow/index/updateWfConfig?name=signinput_default_fontfamily&value=仿宋_GB2312/FangSong_GB2312 | Examples: 宋体/SimSun, 微软雅黑/Microsoft YaHei, Arial/Arial, Helvetica, sans-serif. |
| Default sign font size | /api/workflow/index/updateWfConfig?name=signinput_default_fontsize&value=36/36px | Common values range from 8/8px to 36/36px. |
| Custom browser cache | un_use_customize_browser_cache | 1 disables, 0 enables; cleanup page: /workflow/request/CustomizeBrowserCacheUtil.jsp. |
| HTML support for non-HTML text fields | support_html_textarea_field | SQL append field12345_1; older forms may use field12345_0; Resin restart required. |
| Bottom duration log | show_duration_log | 1 on, 0 off. |
| Lock detail button row on horizontal scroll | detail_locked_button_row | 1 locked, 0 unlocked. |
| Main-field total when detail has no rows | colRule_noRow_empty | 1 zero, 0 empty. |
| PC handwritten sign button | handwrittensign_switch | 1 on, 0 off. |
| Mobile select displayed as radio | mobile_show_radio | 1 on, 0 off. |
| Mobile body/attachment signing | MobileWFOfficeSign.properties | mobileWFOffice=1; mobilePDFSign=1/2/3. |
Common CSS Cases
#| Goal | Style or Config | Notes |
|---|
| Move detail add/delete buttons left | .detailButtonDiv{float:left} | Wrap with <style> inside code blocks; not needed in CSS files. |
| Center cell background image | .imageCell_swap{background-position:center} | Cell custom class: imageCell. |
| Stretch cell background image | .imageCell_swap{background-size:100% 100%} | Same custom class. |
| Browser link color follows cell | browser_color_controlByCell=1 | Enable through updateWfConfig. |
| Force browser link color | .browserColorCell a{color:red !important} | Cell custom class: browserColorCell. |
| Main select minimum width | .selectCell .wea-select{min-width:50px !important} | Cell custom class: selectCell. |
Other Scenario
#- Refresh the mobile workflow list after submitting from a heterogeneous mobile system: redirect to
current Ecology server URL + '/workflow/workflow/WfRefreshList.jsp'. - If mobile access uses a reverse proxy, use the proxy-facing server address.
AI Lookup Keywords
#- Field values:
getFieldValue, changeFieldValue, specialobj, changeMoreField. - Field state:
changeFieldAttr, getFieldCurViewAttr, viewAttr. - Linkage:
triggerFieldAllLinkage, bindFieldChangeEvent, bindDetailFieldChangeEvent. - Detail rows:
addDetailRow, delDetailRow, getDetailAllRowIndexStr, getDetailRowCount. - Browser fields:
appendBrowserDataUrlParam, getBrowserShowName, overrideBrowserProp. - Select fields:
removeSelectOption, controlSelectOption, getSelectShowName. - Sign remarks:
getSignRemark, setSignRemark, appendSignEditorBottomBar. - Config:
updateWfConfig, support_html_textarea_field, MobileWFOfficeSign.properties.