GetContentControlsByTag

function GetContentControlsByTag(sTag: string = null): ApiBlockLvlSdt[] | ApiInlineLvlSdt[]

Description

Returns a list of all content controls in the document with the specified tag name.

Parameters

sTagstringdefault: null

Content control tag.

Returns

ApiBlockLvlSdt[] | ApiInlineLvlSdt[]

Try It

var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var oInlineLvlSdt = Api.CreateInlineLvlSdt();
oParagraph.AddInlineLvlSdt(oInlineLvlSdt);
oInlineLvlSdt.AddText("Inline content control");
oInlineLvlSdt.SetTag("Tag 1");
var oBlockLvlSdt = Api.CreateBlockLvlSdt();
oBlockLvlSdt.GetContent().GetElement(0).AddText("Block text content control");
oBlockLvlSdt.SetTag("Tag 2");
oDocument.AddElement(0, oBlockLvlSdt);
var aContentControls = oDocument.GetContentControlsByTag("Tag 1");
aContentControls[0].SetAlias("№1");

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).