ReplaceByElement
Replaces the current content control with a new element.
Syntax
expression.ReplaceByElement(oElement);
expression - A variable that represents a ApiBlockLvlSdt class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| oElement | Required | DocumentElement | The element to replace the current content control with. |
Returns
boolean
Example
Replace a content control with a regular paragraph in a document.
// How do I replace a content control with a paragraph in a document?
// Swap out a content control for plain text when the structured field is no longer needed in a document.
let doc = Api.GetDocument();
let blockLvlSdt = Api.CreateBlockLvlSdt();
doc.AddElement(0, blockLvlSdt);
blockLvlSdt.SetPlaceholderText("Name");
let paragraph = Api.CreateParagraph();
paragraph.AddText("The content control was replaced with the current paragraph.");
blockLvlSdt.ReplaceByElement(paragraph);