corebos
corebos copied to clipboard
Workflow feedback
Let's say you have a workflow task that updates a field on a related record whenever some condition is true. To us as administrators, that will be easy, but to a lot of users, it'll be vague. So lets say we provide an extra field for every workflow task that will allow you to notify the user of what has been done.
So that when they make that change in record A, after the workflow task has been completed a popup will appear that shows your custom text, like 'Field A on record B has been updated according to your changes'.
The first thought that came to mind would be to send a message to the corebos queue from the workflow system and the use a preViewCheck
hook in the detail view to read the message and show the user the result. You can do the same with a DETAILVIEWWIDGET.
Then I realized that the workflow system did not have support for the message queue so I added that along with an "execute expression" workflow task that makes it easier to do these tasks.
If you don't want to update you can use the coreBOS key-value store to do the same logic.
Even more, you can use presave and preview hooks to directly implement the user message in any way you want.
If you are thinking of making it native I would migrate the event stream drawer we have in coreboscrm and send the message there. That way it doesn't bother at all.
I tested the workflow execute expression task, sending a message and retrieving it in the DetailView with this patch:
diff --git a/modules/Vtiger/DetailView.php b/modules/Vtiger/DetailView.php
index e517ffdf3..47b2522b3 100644
--- a/modules/Vtiger/DetailView.php
+++ b/modules/Vtiger/DetailView.php
@@ -25,6 +25,11 @@ if ($record != '') {
}
$errormessageclass = isset($_REQUEST['error_msgclass']) ? vtlib_purify($_REQUEST['error_msgclass']) : '';
$errormessage = isset($_REQUEST['error_msg']) ? vtlib_purify($_REQUEST['error_msg']) : '';
+$cbmq = coreBOS_MQTM::getInstance();
+$msg = $cbmq->getMessage('workflowMessageChannel', 'wfmessagereader', 'workflow');
+if ($msg) {
+ $errormessage .= print_r($msg, true);
+}
$smarty->assign('ERROR_MESSAGE_CLASS', $errormessageclass);
$smarty->assign('ERROR_MESSAGE', $errormessage);
$focus->preViewCheck($_REQUEST, $smarty);
Wow, a lot of new things for me to read up on. Cool!