Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created July 17, 2023 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/1255d29037142809e2e71a678aaa2c95 to your computer and use it in GitHub Desktop.
Save bjoerntx/1255d29037142809e2e71a678aaa2c95 to your computer and use it in GitHub Desktop.
window.addEventListener("documentViewerLoaded", function () {
var elem = document.querySelector("tx-document-viewer");
elem.shadowRoot.querySelectorAll(".formFieldDiv").forEach((formField) => {
if (values[formField.name] === undefined) return;
var formFieldType = formField.getAttribute("formfieldtype");
var fieldValue = values[formField.name];
switch (formFieldType) {
case "checkbox":
formField.checked = fieldValue;
break;
case "text":
formField.value = fieldValue;
break;
case "selection":
if (formField.nodeName === "INPUT") {
formField.value = fieldValue;
} else if (formField.nodeName === "SELECT") {
formField.querySelectorAll("option").forEach((option) => {
if (option.value === fieldValue) {
option.selected = true;
}
});
}
break;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment