Is there api to add field to the document?
Hello @softboy99
Please specify which field exactly you are referring to. Is it Field from the Insert tab?
Hi,
The field is from my business plugin, i see from 8.2, it support field code
Please take a look at this topic:
Does it match your query?
Hi,
yes, the same. Thanks. wishing
Hi,
almost the same, but , there 's another issue, display the fieldcode in the document editor,like ms word (alt +f9)
Thanks for the reply. We are still working on this query. I will let you know once any news come up.
Hi,
Is there any workaround before your api is ready?
I’m afraid there is not.
any command which can be called? just like ui from insert tab?
Not quite following this reference.
Hello @softboy99
I wanted to inform you that an enhancement suggestion to add methods for interacting with Fields was registered. Methods will be implemented in one of the future releases of Document Server.
Hi,
is it will be available in next major release 9.0?
It should be. As of now it is being verified. I will let you know once it becomes available.
Hello @softboy99
We have just released new version 9.0 of Document Server that brings new method AddField(code)
for inserting a field into a document. Here is an example of usage of this method:
// This example adds the field to the specified range by field instruction code.
// Note: This method removes text within range.
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This text for time field");
let range = paragraph.GetRange();
range.AddField('TIME \\@ "dddd, MMMM d, yyyy"');
paragraph = Api.CreateParagraph();
paragraph.AddText("The text within range was replaced by field with TIME instruction field.");
doc.Push(paragraph);
Pay attention to the way the code is defined – since the code itself contains double quotation marks in it, you need to wrap whole code into a single quotation marks to avoid issues.
Official documentation on this method will become available shortly.