Hello @str
Please provide us with details on desired final goal. Do you mean that request contains an external link to the data with firstname/lastname parameters? If it’s possible, please describe it in detail.
OK, so I have a variant with url: insert_firstname.html, and the code is:
this.callCommand(function() {
var oDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
oParagraph.AddText("«Firstname»");
oDocument.InsertContent([oParagraph]);
}, true);
Then I have another variant with url: insert_lastname.html, and the code is:
this.callCommand(function() {
var oDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
oParagraph.AddText("«Lastname»");
oDocument.InsertContent([oParagraph]);
}, true);
I come from a backend background, and usually, this would be solved by having a single variant, and just pass witch text to add as a variable. Something like defining the variants in the config file like this:
url: “insert.html?type=firstname”
url: “insert.html?type=lastname”
And in the code, in the variant HTML we would have something like:
this.callCommand(function() {
var oDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
var type = Somehow.Plugin.GetParam('type');
oParagraph.AddText("« ' + type +'»");
oDocument.InsertContent([oParagraph]);
}, true);
Sorry for the late reply. I am still thinking that I misunderstand the entire scenario. Are all actions performed in the single file? If so, I was able to achieve it like this:
(function() {
var oDocument = Api.GetDocument();
var oParagraph = Api.CreateParagraph();
oParagraph.AddText("Peter");
oDocument.InsertContent([oParagraph]);
var text1 = "Peter";
var oDocument2 = Api.GetDocument();
var oParagraph2 = Api.CreateParagraph();
oParagraph2.AddText("Parker");
oDocument2.InsertContent([oParagraph2]);
var text2 = "Parker";
var oDocument3 = Api.GetDocument();
var oParagraph3 = Api.CreateParagraph();
oParagraph3.AddText(text1 + " " + text2);
oDocument3.InsertContent([oParagraph3]);
})();
Please let me know if I misunderstood the request.
The “variations” allow me to have a menu from where the user can pick one of different placeholders to insert. If I copy and paste the same 2 files (insert_firstname.html, insert_firstname.js) and paste them for each placeholder (lastname, address, suburb, state, postcode) I will end with 12 files with very little differences.
Would it be possible to pass a variable around, from the plugin config file, so that the variation can point to the same htm/js files and load that variable?
Hello @str
We are going to release the ability to configure a plugin externally (via editor initialization config or the connector class of Automation API). We are planning to include this feature in the next version of Document server. I hope it will match your needs.
If I misunderstood the desired scenario, please clarify it.