# 1 Register User-define event

## 1 Register intercept event, specify action pre-execution trigger, and block/release follow-up actions

> Support multiple registrations, execute in order of registration; support asynchronous ajax, avoid request jam **Scenario 1:** perform custom logic and block/release before submi, save, returnn, forward, withdraw, etc **Scenario 2:** execute custom logic and block/allow follow-up action before add/detele detail row

| Type of action             | Note                                                                                                             | Minimum Version |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------- | --------------- |
| WfForm.OPER\_SAVE          | Save                                                                                                             |                 |
| WfForm.OPER\_SUBMIT        | Submission/approval/submission feedback/no feedback                                                              |                 |
| WfForm.OPER\_SUBMITCONFIRM | Submit to the confirmation page, if it is the confirmation interface, the click confirmation triggers the SUBMIT |                 |
| WfForm.OPER\_REJECT        | Return                                                                                                           |                 |
| WfForm.OPER\_REMARK        | Note submission                                                                                                  |                 |
| WfForm.OPER\_INTERVENE     | Intervention                                                                                                     |                 |
| WfForm.OPER\_FORWARD       | Forwarding                                                                                                       |                 |
| WfForm.OPER\_TAKEBACK      | Compulsory recovery                                                                                              |                 |
| WfForm.OPER\_DELETE        | Delete                                                                                                           |                 |
| WfForm.OPER\_ADDROW        | Add a line of detail and spell the serial number of the list                                                     |                 |
| WfForm.OPER\_DELROW        | Delete the line and spell the list number                                                                        |                 |
| WfForm.OPER\_PRINTPREVIEW  | Print Preview                                                                                                    | KB900190501     |
| WfForm.OPER\_EDITDETAILROW | Mobile - Edit Details                                                                                            | KB900191101     |
| WfForm.OPER\_BEFOREVERIFY  | Check pre-fill trigger event                                                                                     | KB900191201     |

Interface name and parameter description

> registerCheckEvent：function (type, fun)

| Parameters | Parameter type | Required | Remarks                                                                                                                                                                                                                              |
| ---------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| type       | String         | Yes      | Action type (see table above for details), separated by commas                                                                                                                                                                       |
| fun        | Function       | Yes      | The custom function is entered into the body of the success function that performs callback, custom logic completion or asynchronous ajax, and the release needs to be called callback, does not call to block subsequent operations |

Example

```javascript
jQuery().ready (function(){
 WfForm.registerCheckEvent (Wform.OPER_SAVE, function(callback){
 jQuery ("#field27495").val(" Save automatic assign value");
 callback()// continue to submit to callback, no callbacck means break
    });
 WfForm.registerCheckEvent (Wform.OPER_SAVE +,"+WfForm.OPER_SUBMIT,function(callback){
 //... Execute user-defined logic
 callback();
    });
 WfForm.registerCheckEvent (Wform.OPER_ADDROW +"1", function(callback){
 alert (" execute logic before adding detail 1, detail 1 is OPER_ADDROW+1, and so on ");
 callback()// Allows you to continue adding row calls callback, else break
    });
 WfForm.registerCheckEvent (Wform.Oper_DELROW +"2", function(callback){
 alert(" Execution logic before deleting detail 2");
 callback();// Allows continued deletion of line calls callback, else break
    });
 WfForm.registerCheckEvent (Wform.OPER_PRINTPREVIEW, function(callback){
 alert(" Control default print preview window ");
 alert(" this interface needs to be executed before the jump route, the component library provides this mechanism when the component library provides this mechanism ");
 window.WfForm.printTimeout =3000;// product is the default delay 1s to pop-up, can control the delay time here
callback();// Allows continued pop-up calls callback, else break
    });
 WfForm.registerCheckEvent (Wform.Oper_EDITDETAILROW, function (callback, params){
 alert (JSON.stringify (params);/ parameter contains which list and which line is currently clicked
 callback();// Allow jump detail edit window without calling block jump
    });
});
```

## 2 Register hook event, trigger after specific action completed

> Support multiple call registration and execute in order of registration

| Type                              | Note                                                         | Minimum Version |
| --------------------------------- | ------------------------------------------------------------ | --------------- |
| WfForm.ACTION\_ADDROW             | Add a line of detail and spell the serial number of the list | KB900190407     |
| WfForm.ACTION\_DELROW             | Delete the line and spell the list number                    | KB900190407     |
| WfForm.ACTION\_EDITDETAILROW      | Mobile-edit line, list number                                | KB900190501     |
| WfForm.ACTION\_SWITCHDETAILPAGING | Switching detail pages                                       | KB900191201     |
| WfForm.ACTION\_SWITCHTABLAYOUT    | Switch template layout tab                                   | KB900191201     |

Interface name and parameter description

> registerAction：function(actionname, fn)

| Parameters | type     | Required | Remarks                      |
| ---------- | -------- | -------- | ---------------------------- |
| actionname | String   | Yes      | Action type, see table above |
| fn         | Function | Yes      | Trigger event                |
| Example    |          |          |                              |

```javascript
WfForm.registerAction(Wform.ACTION_ADDROW +"1", function(index){
 alert (" Add line subscript" +index);
// subscript from 1, detail 1 add line trigger event, register function entry parameter is new line subscript
WfForm.registerAction(Wform.ACTION_DELROW +"2", function(arg){
 alert (" Delete row subscript set is "+arg.join(","");
});// subscript from 1, detail 2 delete line trigger event
WfForm.registerAction(Wform.ACTION_SWITCHDETAILPAGING, function (groupid){
 alert (" Switching detail table page "+(groupid+1) +"trigger event");//Page number trigger event 
});
WfForm.registerAction (Wform.ACTION_SWITCHTABLAYOUT, function(tabid){
 alert (" Switch to tag item "+tabid+" Trigger event ");
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ec9help.weaver.com.co/1-ec9-workflow-engine-form-api/1-register-user-define-event.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
