• 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
5> **NOTE**
6>
7> 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.
8>
9> The APIs of this module can be used only in the stage model.
10
11## Modules to Import
12```ts
13import { FormEditExtensionAbility } from '@kit.FormKit';
14```
15## FormEditExtensionContext
16You can use **FormEditExtensionContext** to access specific **FormEditExtensionAbility** resources.
17
18### startSecondPage
19
20startSecondPage(want: Want): Promise<[AbilityResult](../apis-ability-kit/js-apis-inner-ability-abilityResult.md)>
21
22Starts the widget provider page to be edited.
23
24**Model restriction**: This API can be used only in the stage model.
25
26**System capability**: SystemCapability.Ability.Form
27
28**Parameters**
29
30  | Name| Type   | Mandatory| Description                                  |
31  | ------ | ------ | ---- | ------------------------------------- |
32  | 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.|
33
34**Return value**
35  | Type| Description   |
36  | ------ | ------ |
37  | Promise<[AbilityResult](../apis-ability-kit/js-apis-inner-ability-abilityResult.md)>  |  Promise used to return the ability result. |
38
39**Error codes**
40
41For details about the error codes, see [Form Error Codes](errorcode-form.md) and [Universal Error Codes](../errorcode-universal.md).
42
43| ID| Error Message                                                    |
44| -------- | ------------------------------------------------------------ |
45| 202      | The application is not a system application.                 |
46| 16500050 | An IPC connection error happened.                            |
47| 16501000 | An internal functional error occurred.                       |
48| 16500100 | Failed to obtain the configuration information.                        |
49
50**Example**
51
52```ts
53import { FormEditExtensionAbility } from '@kit.FormKit'
54import { Want,UIExtensionContentSession } from '@kit.AbilityKit';
55
56const TAG: string = '[testTag] ExampleFormEditExtensionAbility'
57export default class ExampleFormEditAbility extends FormEditExtensionAbility {
58  abilityName: string = 'FormEditSecPageAbility'
59  onSessionCreate(want: Want, session: UIExtensionContentSession) {
60    try {
61      this.context.startSecondPage({
62        bundleName: 'com.example.formEditDemo',
63        parameters: {
64          "secPageAbilityName": this.abilityName
65        }
66
67      }).then(data => {
68        console.log(TAG, `startSecondPage result want: ${JSON.stringify(data)}`)
69      });
70    } catch (e) {
71      console.error(TAG, `startSecondPage failed:${e}`)
72      return
73    }
74  }
75}
76
77```
78