Skip to main content

Autofill fields

Automatically fills in all text fields in the document that have the same placeholder or tip text.

(function () {
let doc = Api.GetDocument();
let forms = doc.GetAllForms();
let tip = "Tip";

// Get the first non-empty input from the forms
let textInput = forms
.filter(form => form.GetFormType() === "textForm" && form.GetTipText() === tip && form.GetText())
.map(form => form.GetText())[0] || "";

// Fill all forms with the specified tip text
forms.forEach(form => {
if (form.GetFormType() === "textForm" && form.GetTipText() === tip) {
form.SetText(textInput);
}
});
})();

Methods used: GetDocument, GetAllForms, GetFormType, GetTipText, GetText, SetText

Result

AutofillFields AutofillFields