Page 1 of 1

Trigger DeleteElementsOperation when a document is opened

Posted: Tue Apr 11, 2023 8:27 am
by antonyterrence
Is it possible to trigger the DeleteElementsOperation author action automatically, say, when a document is opened in the web author?

Re: Trigger DeleteElementsOperation when a document is opened

Posted: Tue Apr 11, 2023 9:35 am
by cristi_talau
Hello,

Triggering actions when a document loads is technically possible using the JS API. You can find more details in this tutorial [1] where you have both the event when the document loads and the code to invoke an operation.

However, modifying the document when it is opened may not be the best UX for an integration. Users may find it confusing that the document is opened directly in a modified state. Depedning on what you are trying to achieve there might be a better solution. If you can give us more details, we may be able to advise you towards a solution.

Best,
Cristian

[1] https://www.oxygenxml.com/maven/com/oxy ... fydoc.html

Re: Trigger DeleteElementsOperation when a document is opened

Posted: Tue Apr 11, 2023 11:32 am
by antonyterrence
Here is what I am trying to achieve:
If <critdates> contains more than 3 <revised> elements, the custom Action should delete the all revised elements except the last three.
I have created an custom action using DeleteElementsOperation. However, writers have to perform the operation manually. I am trying to avoid the manual effort on the part of writers. Instead, automatically execute the action if the current document has more than 3 <revised> elements.

Tool: Oxygen XML Web Author

Re: Trigger DeleteElementsOperation when a document is opened

Posted: Tue Apr 11, 2023 1:01 pm
by cristi_talau
Hello,

One option to implement this would be to delete the old revised elements when new ones are inserted. There are several approaches here:
  • Implement a Schematron validation rule with a Quick fix. The quick fix allows users to delete the old revised elements with a single click,
  • Display a form control button "Delete old revisions" on the last revised element when there are more than 3 elements.
Best,
Cristian

Re: Trigger DeleteElementsOperation when a document is opened

Posted: Tue Apr 11, 2023 1:06 pm
by antonyterrence
We have explored both possibilities. The problem with both approach is that writers have to perform the action by clicking a button or applying a quick fix. Can the quick fix or custom action be triggered when the current document changes or edited? We want to automate the action.

Re: Trigger DeleteElementsOperation when a document is opened

Posted: Wed Apr 12, 2023 8:10 pm
by cristi_talau
Hello,
Another idea would be set up an AuthorDocumentFilter that detects that multiple critdates were inserted and deletes the old ones.
Best,
Cristian