Email custom AssignmentHandler

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

atoms
Ebase User
Posts: 7
Joined: Fri May 03, 2013 2:27 pm
Location: Northampton, UK
Contact:

Email custom AssignmentHandler

#1

Postby atoms » Tue Jul 09, 2013 11:26 am

Hi,

We have a requirement to email the Actor of a Workflow Task when a Task has been assigned to them (note: ALL assignments will be push not pull).

As a result I'm currently writing a custom AssignmentHandler which will extend the XIAssignmentHandler and perform the necessary emailing to the Actor upon a successful assignment.

Now rather than writing ODBC lookups to retrieve the email address of the Actor, and then creating a Java email to send, I wanted (in an ideal world) to use the existing resources within ebase. For example, retrieve the email address from my Users DB resource and send the email using the relevant Email Resource.

Is this possible, i.e. using RuntimeEmailSource or something similar, or am I dreaming :idea:

Thanks,
Aron
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Tue Jul 09, 2013 1:40 pm

Aron,

The short answer to your question is "no". There is no way that you can make use of Ebase resources from Java code. But it occurs to me that there may be a different way of doing this that is much easier:

Instead of using push assignment, change it to use pull i.e. change the assignment type to "Custom" and then (probably) set the userid as the assignment key. Then the system will call the Workflow Assignment Service to do the assignment. This is just an Ebase script so you can use database and email resources or anything else that you need. The assignment service script would then assign the task to the userid that you have passed, so the net result is exactly the same as doing the push assignment.

Hope this makes sense.

Regards
Jon
0 x

atoms
Ebase User
Posts: 7
Joined: Fri May 03, 2013 2:27 pm
Location: Northampton, UK
Contact:

#3

Postby atoms » Tue Jul 09, 2013 2:56 pm

Jon,

Thanks for the response, your suggestions do indeed make sense.

Two things:

1) I'm already using the 'Custom' assignment together with a mix of 'Process attribute' and 'Job opener' within the WF Process, hence why I was looking at writing a custom AssignmentHandler as this allowed me the flexibility to use the appropriate assignment mode for the situation rather than forcing down a single route. Using the 'Custom' method for all assignments would indeed grant me access to the resources but would mean that I'd have to write script to get the userid of the required actor that otherwise is already available by using the 'Job opener' or 'Process attribute' method.

Rock - Me - Hard Place :)

So this brings me to 2). You're response hinted that using the 'Custom' assignment method would be changing to pull assignment. My understanding from the documentation and UML diagrams was that an assignment was only pull if a group was assigned to the task and not an individual actor; using 'Custom' but assigning a single Actor would still be push assignment. Is my understanding therefore incorrect? I ask because this is what led me to the custom AssignmentHandler method and tests lead me to believe that I have access to the ActorId and this method would work with the mix of assignment modes. I may well be wrong and therefore your suggestion of using 'Custom' for all of the assignments indeed seems the best option.

I'd appreciate some clarification on push v pull; for reference I've added the current Workflow Assignment code which I've interpreted as push.

Code: Select all

if ( fields.WFKEY.value == "itr_approval_it"){
	setUserFromITRSystemSetting("APR_IT");
}else if ( fields.WFKEY.value == "itr_approval_cer"){
	setUserFromITRSystemSetting("APR_CER");
}else if ( fields.WFKEY.value == "itr_approval_fin"){
	setUserFromITRSystemSetting("APR_FIN");
}else if ( fields.WFKEY.value == "itr_approval_pur"){fields.
	setUserFromITRSystemSetting("APR_PUR");
}

function setUserFromITRSystemSetting(systemSetting){
	//Retrieve the system setting
	fields.ITR_SYSTEMSETTING_LOOKUP_KEY.value = systemSetting;
	resources.ITR_SYSTEMSETTING.fetch();
	//Set the approver as the resource
	tables.USERS.insertRow();
	tables.USERS.USERID.value = fields.ITR_SYSTEMSETTING_LOOKUP_VALUE.value;
	tables.USERS.updateTable();
}
Thanks,
Aron
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#4

Postby Jon » Tue Jul 09, 2013 3:42 pm

1) Yes, you would need an extra script (System Activity) to extract Job Opener and load it into a process attribute, something like this:

Code: Select all

fields.ATTR1.value = system.variables.$OPENER_RESOURCE.value;
(I haven't tested this.)

You don't need anything extra though to handle assignment by process attribute - as all the process attributes are passed into the assignment service.

2) If the assignment service returns a single user - as per your code - this is treated as a special case: that user is assigned in the same way as if you had chosen assignment by Named Resource or Process Attribute - this is push assignment. In all other cases (when using the assignment service), it will be pull assignment i.e. multiple users returned, or use of roles or credentials. I don't think this is documented anywhere, so sorry about the confusion.

Regards
Jon
0 x

atoms
Ebase User
Posts: 7
Joined: Fri May 03, 2013 2:27 pm
Location: Northampton, UK
Contact:

#5

Postby atoms » Thu Jul 11, 2013 1:31 pm

Jon,

As always thanks for the great help and clarification of point 2).

Aron
0 x

atoms
Ebase User
Posts: 7
Joined: Fri May 03, 2013 2:27 pm
Location: Northampton, UK
Contact:

#6

Postby atoms » Thu Jul 11, 2013 1:35 pm

For anyone else looking into this thread a couple of pointers which may help if you too are implementing a similar solution:

a) There is no need for extra scripts (System Activity) as the $OPENER_RESOURSE, $OWNER_RESOURCE, etc are already available to you in the WF assignment script through:

Code: Select all

system.variables.$OPENER_RESOURCE.value
b) The process attributes are indeed also available to you within the WF assignment script. I didn't find them at first because they are available to you from within the ATTRIBUTES table as opposed to being field values. I created the function below to make it easier to retrieve these values; where the key parameter is the name of the WF process attribute you want to retrieve:

Code: Select all

function getProcessAttribute(key){
 tables.ATTRIBUTES.fetchTable();
 var attributes = tables.ATTRIBUTES;
 var row = attributes.findRow(attributes.ID, key);
 if (row != -1)
 {
   return attributes.getColumnValueOnRow(attributes.VALUE, row);
 }
 return "";
}
c) Finally remember if you need/want to use a resource such as a DB or Email resource it has to be added to the WORKFLOW_SERVICE_BV business view.

Good luck.
0 x


Who is online

Users browsing this forum: No registered users and 22 guests