• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# FormEditExtensionContext
2
3**FormEditExtensionContext**, inherited from [UIExtensionContext](../apis-ability-kit/js-apis-inner-application-uiExtensionContext.md), is the context of [FormEditExtensionAbility](./js-apis-app-form-formEditExtensionAbility.md).
4
5You can use **FormEditExtensionContext** to access specific **FormEditExtensionAbility** resources.
6
7> **NOTE**
8>
9> The initial APIs of this module are supported since API version 18. Newly added APIs will be marked with a superscript to indicate their earliest API version.
10>
11> The APIs of this module can be used only in the stage model.
12
13## Modules to Import
14```ts
15import { FormEditExtensionAbility } from '@kit.FormKit';
16```
17## FormEditExtensionAbility.startSecondPage
18
19startSecondPage(want: Want): Promise<[AbilityResult](../apis-ability-kit/js-apis-inner-ability-abilityResult.md)>
20
21Starts the widget provider page to be edited.
22
23**Model restriction**: This API can be used only in the stage model.
24
25**Atomic service API**: This API can be used in atomic services since API version 18.
26
27**System capability**: SystemCapability.Ability.Form
28
29**Parameters**
30
31  | Name| Type   | Mandatory| Description                                  |
32  | ------ | ------ | ---- | ------------------------------------- |
33  | want  |  [Want](../apis-ability-kit/js-apis-app-ability-want.md)  | Yes  | Information about the editing page that needs to be started by the home screen of a third-party application.|
34
35**Return value**
36  | Type| Description   |
37  | ------ | ------ |
38  | Promise<[AbilityResult](../apis-ability-kit/js-apis-inner-ability-abilityResult.md)>  |  Promise used to return the ability result. |
39
40**Error codes**
41
42For details about the error codes, see [Form Error Codes](errorcode-form.md) and [Universal Error Codes](../errorcode-universal.md).
43
44| ID| Error Message                                                    |
45| -------- | ------------------------------------------------------------ |
46| 202      | The application is not a system application.                 |
47| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. |
48| 16500050 | An IPC connection error happened.                            |
49| 16501000 | An internal functional error occurred.                       |
50| 16500100 | Failed to obtain the configuration information.                        |
51
52**Example**
53
54```ts
55import { FormEditExtensionAbility } from '@kit.FormKit'
56import { Want,UIExtensionContentSession } from '@kit.AbilityKit';
57
58const TAG: string = '[testTag] ExampleFormEditExtensionAbility'
59export default class ExampleFormEditAbility extends FormEditExtensionAbility {
60  abilityName: string = 'FormEditSecPageAbility'
61  onSessionCreate(want: Want, session: UIExtensionContentSession) {
62    try {
63      this.context.startSecondPage({
64        bundleName: 'com.example.formEditDemo',
65        parameters: {
66          "secPageAbilityName": this.abilityName
67        }
68
69      }).then(data => {
70        console.log(TAG, `startSecondPage result want: ${JSON.stringify(data)}`)
71      });
72    } catch (e) {
73      console.error(TAG, `startSecondPage failed:${e}`)
74      return
75    }
76  }
77}
78
79```
80