跳到主要内容

SetFormsData

Sets the data to the specified forms.

Syntax

expression.SetFormsData(arrData);

expression - A variable that represents a ApiDocument class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arrDataRequiredFormData[]An array of form data to set to the specified forms.

Returns

This method doesn't return any data.

Example

This example shows how to set data to forms.

let doc = Api.GetDocument();
let paragraph1 = doc.GetElement(0);
let checkBox = Api.CreateCheckBoxForm({key: "BestCompany"});
paragraph1.Push(checkBox);
let textForm = Api.CreateTextForm({key: "CompanyName"});
paragraph1.Push(textForm);

doc.SetFormsData([
{key: "BestCompany", value: true},
{key: "CompanyName", value: "OnlyOffice"}
]);