Skip to main content
  1. Work Notes/
  2. Reference Docs/

Ecology E10 JS-SDK Quick Reference

·950 words·5 mins
Ecology E10 JS SDK Reference Docs Quick Reference
Author
molefool
Table of Contents

Goal: find the right API by task. This version keeps API names, constants, parameter shapes, examples, and pitfalls, while removing screenshots, GIFs, and long demo text.

Scope
#

  • Global object: window.WeFormSDK.
  • Form instance: window.WeFormSDK.getWeFormInstance(moduleKey?, formId?, dataId?).
  • Entry points: form designer source/code block or the ecode development platform.
  • Async entry: get the instance after window.ebuilderSDK.getPageSDK().on('formReady', callback).
  • Fallback entry: window.onFormReady = function (props) {}, but it is a single global callback and may be overwritten.
  • Runtime check: window.WeFormSDK.isMobile().
window.ebuilderSDK.getPageSDK().on('formReady', function () {
  const weFormSdk = window.WeFormSDK.getWeFormInstance();
  const fieldMark = weFormSdk.convertFieldNameToId('field_code', 'main', true);
  console.log(fieldMark);
});

Instance Lookup
#

CaseAPINotes
Active formwindow.WeFormSDK.getWeFormInstance()Common in simple code blocks.
Module isolationwindow.WeFormSDK.getWeFormInstance(moduleKey)Use when one page has multiple modules.
Module + form isolationwindow.WeFormSDK.getWeFormInstance(moduleKey, formId)Avoid reading another form instance.
Module + form + data isolationwindow.WeFormSDK.getWeFormInstance(moduleKey, formId, dataId)Prefer this on multi-form pages.

Action Events
#

Before-action Guards
#

weFormSdk.registerCheckEvent(type, fn) runs before an operation. Call successFn() to continue; call failFn() or do not continue to block.

ConstantUsage
WeFormSDK.OPER_SAVEBefore save.
WeFormSDK.OPER_ADDROW + detailMarkBefore adding a detail row.
WeFormSDK.OPER_DELROW + detailMarkBefore deleting a detail row.
WeFormSDK.OPER_BEFOREVERIFYBefore required-field validation.
weFormSdk.registerCheckEvent(window.WeFormSDK.OPER_SAVE, function (successFn, failFn) {
  if (window.WeFormSDK.isMobile()) successFn();
  else failFn();
});

After-action Hooks
#

weFormSdk.registerAction(type, fn) runs after an action. It can be registered multiple times and runs in registration order.

ConstantUsage
WeFormSDK.ACTION_ADDROW + detailMarkAfter adding a detail row; callback receives the new row index.
WeFormSDK.ACTION_DELROW + detailMarkAfter deleting detail rows; callback receives deleted indexes.
WeFormSDK.ACTION_FORM_SUBMITAfter form submit.
WeFormSDK.ACTION_FORM_SAVEAfter form save.
WeFormSDK.ACTION_DATA_LINKAGEAfter data linkage completes.
const detailMark = weFormSdk.convertFieldNameToId('detail_code', 'main', true);
weFormSdk.registerAction(window.WeFormSDK.ACTION_ADDROW + detailMark, function (index) {
  console.log('add row:', index);
});

Field APIs
#

TaskAPIKey Point
Convert field code to field markweFormSdk.convertFieldNameToId(fieldName, symbol?, prefix?)symbol can be main or a detail mark; prefix=true returns the field prefix.
Read valueweFormSdk.getFieldValue(fieldMark)Reads text, select values, and browser IDs.
Write valueweFormSdk.changeFieldValue(fieldMark, valueInfo)Triggers linkage/drill actions; option matrix data is not supported.
Change display stateweFormSdk.changeFieldAttr(fieldMark, viewAttr)1 read-only, 2 editable, 3 required, 4 hidden.
Write value and stateweFormSdk.changeSingleField(fieldMark, valueInfo?, variableInfo?)Use for one field when value and state change together.
Batch writeweFormSdk.changeMoreField(changeDatas, changeVariable?)Update many fields in one call.
Get field metadataweFormSdk.getFieldInfo(fieldMark)Returns field name, type, display attribute, and related metadata.

Value Shapes
#

// Text, date, select
weFormSdk.changeFieldValue(textFieldMark, { value: 'text' });
weFormSdk.changeFieldValue(selectFieldMark, { value: '4765016625940566613' });
weFormSdk.changeFieldValue(dateFieldMark, { value: '2026-07-03' });

// Multi-level select or date range usually uses comma-separated values
weFormSdk.changeFieldValue(selectFieldMark, { value: 'id1,id2' });

// Browser fields use specialObj in the E10 reference
weFormSdk.changeFieldValue(browserFieldMark, {
  specialObj: [
    { id: '718974312893816832', name: 'Example 1' },
    { id: '718974312893816833', name: 'Example 2' }
  ]
});

Field Events
#

TaskAPINotes
Main-field changeweFormSdk.bindFieldChangeEvent(fieldMarkStr, fn)Join multiple fields with commas.
Detail-field changeweFormSdk.bindDetailFieldChangeEvent(fieldMarkStr, fn)Works for existing and newly added rows.
Field-area actionweFormSdk.bindFieldAction(type, fieldMarkStr, fn)type supports onblur, onfocus, onclick, ondbclick, mouseover, mouseout.
weFormSdk.bindFieldChangeEvent(textFieldMark + ',' + selectFieldMark, function (id, value) {
  console.log(id, value);
});

Detail-table APIs
#

TaskAPINotes
Add rowweFormSdk.addDetailRow(detailMark, initAddRowData?)initAddRowData can set initial field values.
Delete rowweFormSdk.delDetailRow(detailMark, rowIdMark)Deletes by row mark.
List row marksweFormSdk.getDetailAllRowIndexStr(detailMark)Returns a comma-separated string.
Count rowsweFormSdk.getDetailRowCount(detailMark)Count only; do not use as direct row indexes.
Get display serial by row markweFormSdk.getDetailRowSerailNum(detailMark, rowId)Original API spelling is Serail.
Copy last row on addweFormSdk.setDetailAddUseCopy(detailMark, needCopy)Usually set after initialization.
Get row mark by indexweFormSdk.getDetailRowIdByIndex(detailMark, index)Used by the original demo; verify availability in the target environment.
const detailMark = weFormSdk.convertFieldNameToId('detail_code', 'main', true);
const detailTextMark = weFormSdk.convertFieldNameToId('detail_text');

weFormSdk.addDetailRow(detailMark, {
  [detailTextMark]: { value: 'new detail value' }
});

const rowIds = weFormSdk.getDetailAllRowIndexStr(detailMark);

Global APIs
#

TaskAPINotes
Read form contextweFormSdk.getBaseInfo()Module, form, data, and request context.
Messagewindow.WeFormSDK.showMessage(msg, type?, duration?, isStatic?)Type, duration, and static display can be controlled.
Confirmwindow.WeFormSDK.showConfirm(content, okEvent?, cancelEvent?, otherInfo?, isStatic?)System confirm dialog.
Custom dialogwindow.WeFormSDK.openCustomDialog(prop)The returned object usually supports destroy().
Reload pageweFormSdk.reloadPage(params?)The source signature appears to miss the initial r in one place.
Append submit paramsweFormSdk.appendSubmitParam(params)Read on the server from request parameters.
Trigger required validationweFormSdk.verifyFormRequired(mustAddDetail?, fieldRequired?)Controls required detail and field validation.
Global loadingWeFormSDK.getLoadingGlobal().start/end/destroyUseful around long async work.
window.WeFormSDK.showConfirm('Continue?', function () {
  weFormSdk.appendSubmitParam({ cus_source: 'ecode' });
});

Field-type APIs
#

TaskAPILimit
Add browser data URL paramsweFormSdk.appendBrowserDataUrlParam(fieldMark, jsonParam)Browser fields; backend browser interface must read the params.
Read browser option IDsweFormSdk.getBrowserOptionId(fieldMark, splitChar?)Non-date browser fields; source marks it as pending release.
Read browser display namesweFormSdk.getBrowserShowName(fieldMark, splitChar?)Joins multiple values with splitChar.
Remove select optionsweFormSdk.removeSelectOption(fieldMark, optionKeys)Select fields; comma-separated option keys.
Read select display namesweFormSdk.getSelectShowName(fieldMark, splitChar?)Select fields.
Read option browser entityweFormSdk.getBrowserOptionEntity(fieldMark, splitChar?)Option-like fields; verify in the target environment because the source example is inconsistent.

Reusable Templates
#

Field Linkage
#

window.ebuilderSDK.getPageSDK().on('formReady', function () {
  const weFormSdk = window.WeFormSDK.getWeFormInstance();
  const source = weFormSdk.convertFieldNameToId('source_code');
  const target = weFormSdk.convertFieldNameToId('target_code');

  function syncValue() {
    const value = weFormSdk.getFieldValue(source);
    weFormSdk.changeFieldValue(target, { value: value });
  }

  syncValue();
  weFormSdk.bindFieldChangeEvent(source, syncValue);
});

Detail Iteration
#

const detailMark = weFormSdk.convertFieldNameToId('detail_code', 'main', true);
const rowIdStr = weFormSdk.getDetailAllRowIndexStr(detailMark);
const rows = rowIdStr ? rowIdStr.split(',') : [];

rows.forEach(function (rowId) {
  const fieldMark = detailFieldMark + '_' + rowId;
  console.log(weFormSdk.getFieldValue(fieldMark));
});

Pitfalls
#

  • In ecode, do not keep the weFormSdk instance in a long-lived global variable; save/refresh actions may replace the form instance.
  • If field marks or getBaseInfo() return undefined, the code is probably running too early; move it into formReady.
  • On pages with multiple forms, prefer getWeFormInstance(moduleKey, formId, dataId).
  • Prefer changeFieldValue and other SDK APIs over direct DOM operations.
  • Browser field assignment uses specialObj in this E10 reference; E9 examples commonly use specialobj.

Related