Send message to UI from action validation

He we will discuss about how to make customization and improvement to the OpenKM source code.
Forum rules
Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
Post Reply
fgeymonat
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: Sat Aug 03, 2019 6:13 pm

Send message to UI from action validation

Post by fgeymonat »

Hi, I´ve implemented an action when the textextracted event happens, and i need to implement a validation for this action, so that if the validation is true action is executed, and if the validation is false the action isn´t executed. The question is: is there a way to show the user a custom message in these cases?.
Is it possible to send a message from within a validation to the user interface?.
Thank you very much and regards,
Fernando

jllort
Moderator
Moderator
Posts: 11204
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Send message to UI from action validation

Post by jllort »

Ufff, should understanding with more detail the problem you are trying to solve, but well anyway I will try to advance some ideas:
1- text extractor happens in the background, that means the user may be is not in the UI etc...
2- another question is ... what user should be updated ... I suppose we are talking about the creator of the document ( or the last person who has updated ).

I suppose you have how to create automation action -> and validation ( otherwise ask for it ).
I suggest you create a table to keep ( document UUID and additional information you need ), each time validation be true to keep data in the table. Finally, one time per day execute a crontab task and send to each user the information about the document processed.
If the user must do some action I will need some explanation about what to suggest a way to solve it ( maybe metadata, or workflow etc... because are several solutions I would like a sample of the action what it is supposed to do the user with the document )

fgeymonat
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: Sat Aug 03, 2019 6:13 pm

Re: Send message to UI from action validation

Post by fgeymonat »

I was wrong in the event name that i told you. Indeed, the event that is executed and i want to validate is RenameDocument. When the user right-clicks on a document and tries to rename it, if the name does not meet certain pattern, i would like to display a message that indicates it. Is it possible to show a message to the user if the validation fails?.
Thank you very much!

jllort
Moderator
Moderator
Posts: 11204
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Send message to UI from action validation

Post by jllort »

You can execute this validation from automation Action and raise and exception ( will be shown error explanation in a popup ) when the pattern is wrong. You must build an action for it. The Action must be execute before the document be renamed in "pre" stage.

Here it is explained how to build an Action https://docs.openkm.com/kcenter/view/ok ... ted-).html
You should linkt the action with evente "document_rename".
Finally take a look at DBDocumentModule.java class https://docs.openkm.com/kcenter/view/ok ... ted-).html in the rename method, basically in the next line:

Code: Select all

AutomationManager.getInstance().fireEvent(AutomationRule.EVENT_DOCUMENT_RENAME, AutomationRule.AT_PRE, env);
Should be done a small code modification to add the newName in the map ( map is data what you have available from Automation Action ).

Post Reply