1# @ohos.app.form.formProvider (formProvider) 2<!--Kit: Form Kit--> 3<!--Subsystem: Ability--> 4<!--Owner: @cx983299475--> 5<!--Designer: @xueyulong--> 6<!--Tester: @chenmingze--> 7<!--Adviser: @Brilliantry_Rui--> 8 9The **formProvider** module provides APIs to obtain widget information, update widgets, and set the update time. 10 11> **NOTE** 12> 13> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 14 15## Modules to Import 16 17```ts 18import { formProvider } from '@kit.FormKit'; 19``` 20 21## formProvider.setFormNextRefreshTime 22 23setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback<void>): void 24 25Sets the next refresh time for a widget. This API uses an asynchronous callback to return the result. 26 27**Atomic service API**: This API can be used in atomic services since API version 11. 28 29**System capability**: SystemCapability.Ability.Form 30 31**Parameters** 32 33| Name| Type | Mandatory| Description | 34| ------ | ------ | ---- | ------------------------------------- | 35| formId | string | Yes | Widget ID. | 36| minute | number | Yes | Time after which a widget is updated. The value is greater than or equal to 5, in minutes. | 37| callback | AsyncCallback<void> | Yes| Callback used to return the result.| 38 39**Error codes** 40 41For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 42 43| Error Code ID| Error Message| 44| -------- | -------- | 45| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 46| 16500050 | IPC connection error. | 47| 16500060 | Service connection error. | 48| 16500100 | Failed to obtain the configuration information. | 49| 16501000 | An internal functional error occurred. | 50| 16501001 | The ID of the form to be operated does not exist. | 51| 16501002 | The number of forms exceeds the maximum allowed. | 52| 16501003 | The form cannot be operated by the current application. | 53 54**Example** 55 56```ts 57import { formProvider } from '@kit.FormKit'; 58import { BusinessError } from '@kit.BasicServicesKit'; 59 60let formId: string = '12400633174999288'; 61try { 62 formProvider.setFormNextRefreshTime(formId, 5, (error: BusinessError) => { 63 if (error) { 64 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 65 return; 66 } 67 console.log(`formProvider setFormNextRefreshTime success`); 68 }); 69} catch (error) { 70 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 71} 72``` 73 74## formProvider.setFormNextRefreshTime 75 76setFormNextRefreshTime(formId: string, minute: number): Promise<void> 77 78Sets the next refresh time for a widget. This API uses a promise to return the result. 79 80**Atomic service API**: This API can be used in atomic services since API version 11. 81 82**System capability**: SystemCapability.Ability.Form 83 84**Parameters** 85 86| Name| Type | Mandatory| Description | 87| ------ | ------ | ---- | ------------------------------------- | 88| formId | string | Yes | Widget ID. | 89| minute | number | Yes | Time after which a widget is updated. The value is greater than or equal to 5, in minutes. | 90 91**Return value** 92 93| Type | Description | 94| ------------- | ---------------------------------- | 95| Promise\<void> | Promise that returns no value. | 96 97**Error codes** 98 99For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 100 101| Error Code ID| Error Message| 102| -------- | -------- | 103| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 104| 16500050 | IPC connection error. | 105| 16500060 | Service connection error. | 106| 16500100 | Failed to obtain the configuration information. | 107| 16501000 | An internal functional error occurred. | 108| 16501001 | The ID of the form to be operated does not exist. | 109| 16501002 | The number of forms exceeds the maximum allowed. | 110| 16501003 | The form cannot be operated by the current application. | 111 112**Example** 113 114```ts 115import { formProvider } from '@kit.FormKit'; 116import { BusinessError } from '@kit.BasicServicesKit'; 117 118let formId: string = '12400633174999288'; 119try { 120 formProvider.setFormNextRefreshTime(formId, 5).then(() => { 121 console.log(`formProvider setFormNextRefreshTime success`); 122 }).catch((error: BusinessError) => { 123 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 124 }); 125} catch (error) { 126 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 127} 128``` 129 130## formProvider.updateForm 131 132updateForm(formId: string, formBindingData: formBindingData.FormBindingData,callback: AsyncCallback<void>): void 133 134Updates a widget. This API uses an asynchronous callback to return the result. 135 136**Atomic service API**: This API can be used in atomic services since API version 11. 137 138**System capability**: SystemCapability.Ability.Form 139 140**Parameters** 141 142| Name| Type | Mandatory| Description | 143| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 144| formId | string | Yes | ID of the widget to update.| 145| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. | 146| callback | AsyncCallback<void> | Yes| Callback used to return the result.| 147 148**Error codes** 149 150For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 151 152| Error Code ID| Error Message| 153| -------- | -------- | 154| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 155| 16500050 | IPC connection error. | 156| 16500060 | Service connection error. | 157| 16500100 | Failed to obtain the configuration information. | 158| 16501000 | An internal functional error occurred. | 159| 16501001 | The ID of the form to be operated does not exist. | 160| 16501003 | The form cannot be operated by the current application. | 161 162**Example** 163 164```ts 165import { formBindingData, formProvider } from '@kit.FormKit'; 166import { BusinessError } from '@kit.BasicServicesKit'; 167 168let formId: string = '12400633174999288'; 169try { 170 let param: Record<string, string> = { 171 'temperature': '22c', 172 'time': '22:00' 173 } 174 let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 175 formProvider.updateForm(formId, obj, (error: BusinessError) => { 176 if (error) { 177 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 178 return; 179 } 180 console.log(`formProvider updateForm success`); 181 }); 182} catch (error) { 183 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 184} 185``` 186 187## formProvider.updateForm 188 189updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise<void> 190 191Updates a widget. This API uses a promise to return the result. 192 193**Atomic service API**: This API can be used in atomic services since API version 11. 194 195**System capability**: SystemCapability.Ability.Form 196 197**Parameters** 198 199| Name| Type | Mandatory| Description | 200| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | 201| formId | string | Yes | ID of the widget to update.| 202| formBindingData | [formBindingData.FormBindingData](js-apis-app-form-formBindingData.md#formbindingdata) | Yes | Data to be used for the update. | 203 204**Return value** 205 206| Type | Description | 207| -------------- | ----------------------------------- | 208| Promise\<void> | Promise that returns no value.| 209 210**Error codes** 211 212For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 213 214| Error Code ID| Error Message| 215| -------- | -------- | 216| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 217| 16500050 | IPC connection error. | 218| 16500060 | Service connection error. | 219| 16500100 | Failed to obtain the configuration information. | 220| 16501000 | An internal functional error occurred. | 221| 16501001 | The ID of the form to be operated does not exist. | 222| 16501003 | The form cannot be operated by the current application. | 223 224**Example** 225 226```ts 227import { formBindingData, formProvider } from '@kit.FormKit'; 228import { BusinessError } from '@kit.BasicServicesKit'; 229 230let formId: string = '12400633174999288'; 231let param: Record<string, string> = { 232 'temperature': '22c', 233 'time': '22:00' 234} 235let obj: formBindingData.FormBindingData = formBindingData.createFormBindingData(param); 236try { 237 formProvider.updateForm(formId, obj).then(() => { 238 console.log(`formProvider updateForm success`); 239 }).catch((error: BusinessError) => { 240 console.error(`promise error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 241 }); 242} catch (error) { 243 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 244} 245``` 246 247## formProvider.getFormsInfo 248 249getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): void 250 251Obtains the application's widget information on the device. This API uses an asynchronous callback to return the result. 252 253**Atomic service API**: This API can be used in atomic services since API version 11. 254 255**System capability**: SystemCapability.Ability.Form 256 257**Parameters** 258 259| Name| Type | Mandatory| Description | 260| ------ | ------ | ---- | ------- | 261| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.| 262 263**Error codes** 264 265For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 266 267| Error Code ID| Error Message| 268| -------- | -------- | 269| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 270| 16500050 | IPC connection error. | 271| 16500100 | Failed to obtain the configuration information. | 272| 16501000 | An internal functional error occurred. | 273 274**Example** 275 276```ts 277import { formProvider } from '@kit.FormKit'; 278import { BusinessError } from '@kit.BasicServicesKit'; 279 280try { 281 formProvider.getFormsInfo((error, data) => { 282 if (error) { 283 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 284 return; 285 } 286 console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`); 287 }); 288} catch (error) { 289 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 290} 291``` 292## formProvider.getFormsInfo 293 294getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array<formInfo.FormInfo>>): void 295 296Obtains the application's widget information that meets a filter criterion on the device. This API uses an asynchronous callback to return the result. 297 298**Atomic service API**: This API can be used in atomic services since API version 11. 299 300**System capability**: SystemCapability.Ability.Form 301 302**Parameters** 303 304| Name| Type | Mandatory| Description | 305| ------ | ------ | ---- | ------- | 306| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | Yes| Filter criterion.| 307| callback | AsyncCallback<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Yes| Callback used to return the information obtained.| 308 309**Error codes** 310 311For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 312 313| Error Code ID| Error Message| 314| -------- | -------- | 315| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 316| 16500050 | IPC connection error. | 317| 16500100 | Failed to obtain the configuration information. | 318| 16501000 | An internal functional error occurred. | 319 320**Example** 321 322```ts 323import { formInfo, formProvider } from '@kit.FormKit'; 324import { BusinessError } from '@kit.BasicServicesKit'; 325 326const filter: formInfo.FormInfoFilter = { 327 // get info of forms belong to module entry. 328 moduleName: 'entry' 329}; 330try { 331 formProvider.getFormsInfo(filter, (error, data) => { 332 if (error) { 333 console.error(`callback error, code: ${error.code}, message: ${error.message})`); 334 return; 335 } 336 console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`); 337 }); 338} catch (error) { 339 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 340} 341``` 342 343## formProvider.getFormsInfo 344 345getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.FormInfo>> 346 347Obtains the application's widget information on the device. This API uses a promise to return the result. 348 349**Atomic service API**: This API can be used in atomic services since API version 11. 350 351**System capability**: SystemCapability.Ability.Form 352 353**Parameters** 354 355| Name| Type | Mandatory| Description | 356| ------ | ------ | ---- | ------- | 357| filter | [formInfo.FormInfoFilter](js-apis-app-form-formInfo.md#forminfofilter) | No| Filter criterion. By default, no value is passed, indicating that no filtering is performed.| 358 359**Return value** 360 361| Type | Description | 362| :------------ | :---------------------------------- | 363| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.| 364 365**Error codes** 366 367For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 368 369| Error Code ID| Error Message| 370| -------- | -------- | 371| 401 | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types; 3.Parameter verification failed. | 372| 16500050 | IPC connection error. | 373| 16500100 | Failed to obtain the configuration information. | 374| 16501000 | An internal functional error occurred. | 375 376**Example** 377 378```ts 379import { formInfo, formProvider } from '@kit.FormKit'; 380import { BusinessError } from '@kit.BasicServicesKit'; 381 382const filter: formInfo.FormInfoFilter = { 383 // get info of forms belong to module entry. 384 moduleName: 'entry' 385}; 386try { 387 formProvider.getFormsInfo(filter).then((data: formInfo.FormInfo[]) => { 388 console.log(`formProvider getFormsInfo, data: ${JSON.stringify(data)}`); 389 }).catch((error: BusinessError) => { 390 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 391 }); 392} catch (error) { 393 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 394} 395``` 396 397## formProvider.openFormEditAbility<sup>18+</sup> 398 399openFormEditAbility(abilityName: string, formId: string, isMainPage?: boolean): void 400 401Opens the widget editing page. 402 403**System capability**: SystemCapability.Ability.Form 404 405**Parameters** 406 407| Name| Type | Mandatory| Description | 408| ------ | ------ |----|----------------------------------------------------| 409| abilityName | string | Yes | Ability name on the editing page. | 410| formId | string | Yes | Widget ID. | 411| isMainPage | boolean | No | Whether the page is the main editing page. The value **true** (default) means that the page is the main editing page; the value **false** means the opposite.<br> | 412 413**Error codes** 414 415For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 416 417| Error Code ID | Error Message| 418|----------| -------- | 419| 801 | Capability not supported.function openFormEditAbility can not work correctly due to limited device capabilities. | 420| 16500050 | IPC connection error. | 421| 16500100 | Failed to obtain the configuration information. | 422| 16501000 | An internal functional error occurred. | 423| 16501003 | The form cannot be operated by the current application. | 424| 16501007 | Form is not trust. | 425 426**Example** 427 428```ts 429import { router } from '@kit.ArkUI'; 430 431const TAG: string = 'FormEditDemo-Page] -->'; 432 433@Entry 434@Component 435struct Page { 436 @State message: string = 'Hello World'; 437 438 aboutToAppear(): void { 439 console.log(`${TAG} aboutToAppear.....`); 440 } 441 442 build() { 443 RelativeContainer() { 444 Text(this.message) 445 .id('PageHelloWorld') 446 .fontSize(50) 447 .fontWeight(FontWeight.Bold) 448 .alignRules({ 449 center: { anchor: '__container__', align: VerticalAlign.Top }, 450 middle: { anchor: '__container__', align: HorizontalAlign.Center } 451 }) 452 .onClick(() => { 453 console.log(`${TAG} onClick.....`); 454 formProvider.openFormEditAbility('ability://EntryFormEditAbility', '1386529921'); 455 }) 456 } 457 .height('100%') 458 .width('100%') 459 } 460} 461``` 462 463## formProvider.openFormManager<sup>18+</sup> 464 465openFormManager(want: Want): void 466 467Opens the Widget Manager page. 468 469**Atomic service API**: This API can be used in atomic services since API version 18. 470 471**System capability**: SystemCapability.Ability.Form 472 473**Parameters** 474 475| Name | Type | Mandatory| Description | 476|------| ------ | ---- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 477| want | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Parameter that must contain the following fields:<br>**bundleName**: bundle name of widget.<br>**abilityName**: ability name of the widget.<br>**parameters**:<br>- **ohos.extra.param.key.form_dimension**: [Widget dimension](js-apis-app-form-formInfo.md#formdimension).<br>- **ohos.extra.param.key.form_name**: Widget name.<br>- **ohos.extra.param.key.module_name**: module name of the widget.| 478 479**Error codes** 480 481For details about the error codes, see [Form Error Codes](errorcode-form.md). 482 483| Error Code ID| Error Message| 484| -------- | -------- | 485| 16500050 | IPC connection error. | 486| 16500100 | Failed to obtain the configuration information. | 487| 16501000 | An internal functional error occurred. | 488 489**Example** 490 491```ts 492import { formProvider } from '@kit.FormKit'; 493import { BusinessError } from '@kit.BasicServicesKit'; 494import { Want } from '@kit.AbilityKit'; 495 496const want: Want = { 497 bundleName: 'com.example.formbutton', 498 abilityName: 'EntryFormAbility', 499 parameters: { 500 'ohos.extra.param.key.form_dimension': 2, 501 'ohos.extra.param.key.form_name': 'widget', 502 'ohos.extra.param.key.module_name': 'entry' 503 }, 504}; 505try { 506 formProvider.openFormManager(want); 507} catch (error) { 508 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 509} 510``` 511 512## formProvider.getPublishedFormInfoById<sup>(deprecated)</sup> 513 514getPublishedFormInfoById(formId: string): Promise<formInfo.FormInfo> 515 516Obtains the information of the widget that has been added to the home screen on the device. This API uses a promise to return the result. 517 518**Atomic service API**: This API can be used in atomic services since API version 18. 519 520> **NOTE** 521> 522> This field is supported since API version 18 and deprecated since API version 20. You are advised to use [getPublishedRunningFormInfoById](#formprovidergetpublishedrunningforminfobyid20) instead. 523 524**System capability**: SystemCapability.Ability.Form 525 526**Parameters** 527 528| Name| Type | Mandatory| Description | 529| ------ | ------ |----| ------- | 530| formId | string | Yes| Widget ID.| 531 532**Return value** 533 534| Type | Description | 535|-------------------------------------------------------------------| ---------------------------------- | 536| Promise<[formInfo.FormInfo](js-apis-app-form-formInfo.md#forminfo)> | Promise used to return the information obtained.| 537 538**Error codes** 539 540For details about the error codes, see [Form Error Codes](errorcode-form.md). 541 542| Error Code ID| Error Message| 543| -------- | -------- | 544| 16500050 | IPC connection error. | 545| 16500100 | Failed to obtain the configuration information. | 546| 16501000 | An internal functional error occurred. | 547 548**Example** 549 550```ts 551import { formInfo, formProvider } from '@kit.FormKit'; 552import { BusinessError } from '@kit.BasicServicesKit'; 553 554const formId: string = '388344236'; 555try { 556 formProvider.getPublishedFormInfoById(formId).then((data: formInfo.FormInfo) => { 557 console.log(`formProvider getPublishedFormInfoById, data: ${JSON.stringify(data)}`); 558 }).catch((error: BusinessError) => { 559 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 560 }); 561} catch (error) { 562 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 563} 564``` 565 566## formProvider.getPublishedFormInfos<sup>(deprecated)</sup> 567 568getPublishedFormInfos(): Promise<Array<formInfo.FormInfo>> 569 570Obtains the information of all widgets that have been added to the home screen on the device. This API uses a promise to return the result. 571 572**Atomic service API**: This API can be used in atomic services since API version 18. 573 574> **NOTE** 575> 576> This field is supported since API version 18 and deprecated since API version 20. You are advised to use [getPublishedRunningFormInfos](#formprovidergetpublishedrunningforminfos20) instead. 577 578**System capability**: SystemCapability.Ability.Form 579 580**Return value** 581 582| Type | Description | 583| ------------ | ---------------------------------- | 584| Promise<Array<[formInfo.FormInfo](js-apis-app-form-formInfo.md)>> | Promise used to return the information obtained.| 585 586**Error codes** 587 588For details about the error codes, see [Form Error Codes](errorcode-form.md). 589 590| Error Code ID| Error Message| 591| -------- | -------- | 592| 16500050 | IPC connection error. | 593| 16500100 | Failed to obtain the configuration information. | 594| 16501000 | An internal functional error occurred. | 595 596**Example** 597 598```ts 599import { formInfo, formProvider } from '@kit.FormKit'; 600import { BusinessError } from '@kit.BasicServicesKit'; 601 602try { 603 formProvider.getPublishedFormInfos().then((data: formInfo.FormInfo[]) => { 604 console.log(`formProvider getPublishedFormInfos, data: ${JSON.stringify(data)}`); 605 }).catch((error: BusinessError) => { 606 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 607 }); 608} catch (error) { 609 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 610} 611``` 612 613## formProvider.requestOverflow<sup>20+</sup> 614 615requestOverflow(formId: string, overflowInfo: formInfo.OverflowInfo): Promise<void> 616 617Requests an animation. This API takes effect only for [scene-based widgets](../../form/arkts-ui-widget-configuration.md#sceneanimationparams-field). This API uses a promise to return the result. 618 619**Atomic service API**: This API can be used in atomic services since API version 20. 620 621**System capability**: SystemCapability.Ability.Form 622 623**Parameters** 624 625| Name| Type | Mandatory| Description | 626| ------ |--------------------------------------------------------------------| ---- |-----------| 627| formId | string | Yes| Widget ID.| 628| overflowInfo | [formInfo.OverflowInfo](js-apis-app-form-formInfo.md#overflowinfo20) | Yes| Animation request parameter information.| 629 630**Return value** 631 632| Type| Description| 633| -------- | -------- | 634| Promise<void> | Promise that returns no value.| 635 636**Error codes** 637 638For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 639 640| Error Code ID| Error Message| 641| -------- | -------- | 642| 801 | Capability not supported.function requestOverflow can not work correctly due to limited device capabilities. | 643| 16500050 | IPC connection error. | 644| 16500060 | Service connection error. | 645| 16500100 | Failed to obtain the configuration information. | 646| 16501000 | An internal functional error occurred. | 647| 16501001 | The ID of the form to be operated does not exist. | 648| 16501003 | The form cannot be operated by the current application. | 649| 16501011 | The form can not support this operation. | 650 651**Example** 652 653```ts 654import { formInfo, formProvider } from '@kit.FormKit'; 655import { BusinessError } from '@kit.BasicServicesKit'; 656 657let formId: string = '12400633174999288'; 658let overflowInfo: formInfo.OverflowInfo = { 659 area: { 660 left: -10, 661 top: -10, 662 width: 180, 663 height: 180 664 }, 665 duration: 1000, 666 useDefaultAnimation: false, 667}; 668 669try { 670 formProvider.requestOverflow(formId, overflowInfo).then(() => { 671 console.info('requestOverflow succeed.'); 672 }).catch((error: BusinessError) => { 673 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 674 }); 675} catch (error) { 676 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 677} 678``` 679 680## formProvider.cancelOverflow<sup>20+</sup> 681 682cancelOverflow(formId: string): Promise<void> 683 684Cancels an animation. This API takes effect only for [scene-based widgets](../../form/arkts-ui-widget-configuration.md#sceneanimationparams-field). This API uses a promise to return the result. 685 686**Atomic service API**: This API can be used in atomic services since API version 20. 687 688**System capability**: SystemCapability.Ability.Form 689 690**Parameters** 691 692| Name| Type | Mandatory| Description | 693| ------ | ------ | ---- |-------| 694| formId | string | Yes| Widget ID.| 695 696**Return value** 697 698| Type| Description| 699| -------- | -------- | 700| Promise<void> | Promise that returns no value.| 701 702**Error codes** 703 704For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 705 706| Error Code ID| Error Message| 707| -------- | -------- | 708| 801 | Capability not supported.function cancelOverflow can not work correctly due to limited device capabilities. | 709| 16500050 | IPC connection error. | 710| 16500060 | Service connection error. | 711| 16500100 | Failed to obtain the configuration information. | 712| 16501000 | An internal functional error occurred. | 713| 16501001 | The ID of the form to be operated does not exist. | 714| 16501003 | The form cannot be operated by the current application. | 715| 16501011 | The form can not support this operation. | 716 717**Example** 718 719```ts 720import { formProvider } from '@kit.FormKit'; 721import { BusinessError } from '@kit.BasicServicesKit'; 722 723let formId: string = '12400633174999288'; 724 725try { 726 formProvider.cancelOverflow(formId).then(() => { 727 console.info('cancelOverflow succeed.'); 728 }).catch((error: BusinessError) => { 729 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 730 }); 731} catch (error) { 732 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 733} 734``` 735 736## formProvider.getFormRect<sup>20+</sup> 737 738getFormRect(formId: string): Promise<formInfo.Rect> 739 740Obtains the position and dimension of a widget. This API uses a promise to return the result. 741 742**Atomic service API**: This API can be used in atomic services since API version 20. 743 744**System capability**: SystemCapability.Ability.Form 745 746**Parameters** 747 748| Name| Type | Mandatory| Description | 749| ------ |-------------| ---- |-----------| 750| formId | string | Yes| Widget ID.| 751 752**Return value** 753 754| Type| Description| 755| -------- | -------- | 756| Promise<[formInfo.Rect](js-apis-app-form-formInfo.md#rect20)> | Promise used to return the position and dimension of the widget relative to the upper left corner of the screen, in vp.| 757 758**Error codes** 759 760For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Form Error Codes](errorcode-form.md). 761 762| Error Code ID| Error Message| 763| -------- | -------- | 764| 801 | Capability not supported.function getFormRect can not work correctly due to limited device capabilities. | 765| 16500050 | IPC connection error. | 766| 16500060 | Service connection error. | 767| 16500100 | Failed to obtain the configuration information. | 768| 16501000 | An internal functional error occurred. | 769| 16501001 | The ID of the form to be operated does not exist. | 770| 16501003 | The form cannot be operated by the current application. | 771 772**Example** 773 774```ts 775import { formInfo, formProvider } from '@kit.FormKit'; 776import { BusinessError } from '@kit.BasicServicesKit'; 777 778let formId: string = '12400633174999288'; 779 780try { 781 formProvider.getFormRect(formId).then((data: formInfo.Rect) => { 782 console.info(`getFormRect succeed, data: ${JSON.stringify(data)}`); 783 }); 784} catch (error) { 785 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 786} 787``` 788 789## formProvider.getPublishedRunningFormInfoById<sup>20+</sup> 790 791getPublishedRunningFormInfoById(formId: string): Promise<formInfo.RunningFormInfo> 792 793Obtains the information of a specified widget that has been added to the home screen. This API uses a promise to return the result. 794 795**Atomic service API**: This API can be used in atomic services since API version 20. 796 797**System capability**: SystemCapability.Ability.Form 798 799**Parameters** 800 801| Name| Type | Mandatory| Description | 802| ------ | ------ |----| ------- | 803| formId | string | Yes| Widget ID.| 804 805**Return value** 806 807| Type | Description | 808|-------------------------------------------------------------------| ---------------------------------- | 809| Promise<[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md#runningforminfo20)> | Promise used to return the information about the widgets that meet the requirements, including the widget name and dimension.| 810 811**Error codes** 812 813For details about the error codes, see [Form Error Codes](errorcode-form.md). 814 815| Error Code ID| Error Message| 816| -------- | -------- | 817| 16500050 | IPC connection error. | 818| 16500100 | Failed to obtain the configuration information. | 819| 16501000 | An internal functional error occurred. | 820| 16501001 | The ID of the form to be operated does not exist. | 821| 16501003 | The form cannot be operated by the current application. | 822 823 824**Example** 825 826```ts 827import { formInfo, formProvider } from '@kit.FormKit'; 828import { BusinessError } from '@kit.BasicServicesKit'; 829 830const formId: string = '388344236'; 831 832try { 833 formProvider.getPublishedRunningFormInfoById(formId).then((data: formInfo.RunningFormInfo) => { 834 console.info(`formProvider getPublishedRunningFormInfoById, data: ${JSON.stringify(data)}`); 835 }).catch((error: BusinessError) => { 836 console.error(`promise error, code: ${error.code}, message: ${error.message}`); 837 }); 838} catch (error) { 839 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message}`); 840} 841``` 842 843## formProvider.getPublishedRunningFormInfos<sup>20+</sup> 844 845getPublishedRunningFormInfos(): Promise<Array<formInfo.RunningFormInfo>> 846 847Obtains information about all widgets that have been added to the home screen. This API uses a promise to return the result. 848 849**Atomic service API**: This API can be used in atomic services since API version 20. 850 851**System capability**: SystemCapability.Ability.Form 852 853**Return value** 854 855| Type | Description | 856| ------------ | ---------------------------------- | 857| Promise<Array<[formInfo.RunningFormInfo](js-apis-app-form-formInfo.md#runningforminfo20)>> | Promise used to return the information about widgets that meet the requirements.| 858 859**Error codes** 860 861For details about the error codes, see [Form Error Codes](errorcode-form.md). 862 863| Error Code ID| Error Message| 864| -------- | -------- | 865| 16500050 | IPC connection error. | 866| 16500100 | Failed to obtain the configuration information. | 867| 16501000 | An internal functional error occurred. | 868 869**Example** 870 871```ts 872import { formInfo, formProvider } from '@kit.FormKit'; 873import { BusinessError } from '@kit.BasicServicesKit'; 874 875try { 876 formProvider.getPublishedRunningFormInfos().then((data: formInfo.RunningFormInfo[]) => { 877 console.info(`formProvider getPublishedRunningFormInfos, data: ${JSON.stringify(data)}`); 878 }).catch((error: BusinessError) => { 879 console.error(`promise error, code: ${error.code}, message: ${error.message})`); 880 }); 881} catch (error) { 882 console.error(`catch error, code: ${(error as BusinessError).code}, message: ${(error as BusinessError).message})`); 883} 884``` 885