Am doing publish and wait concept to publish canonical document and getting back taskURL in to CAF project and opening the task URL, task is opening but auto accept is not happening even it is auto accept =true in task project, if iopen same task from task queue inbox auto accept is working fine with acceptBy value with user name , even from task list management if i open task,auto accept is not happening, can any one help me if open taskURL which is return by publish and waitt, auto accept should work.
The auto accept = true is a feature implemented by the custom task inbox, that is why it isn’t auto accepted when you invoke the API or use the TLM. You’ll need to invoke the same code from the API if you want the task auto-accepted. Have a look at the links that the Task Inbox creates to learn how to mark the task accepted.
The API (getCanUserAcceptTask) is just a permissions check, not a ‘logic’ check. By default only one user can accept a task at a time, so below i show an algorithm that un-accepts the task if previously accepted and accepts the task for the current user. Hope this helps.
–mark
//Get a reference to the task provider
ManualAcceptTask mat = getManualAcceptTask();
//is the current user already accepted
if (!mat.isCurrentUserAccepted()) {
//If interested, have a look at the current
//accepted list and the maximum allowed to accept (default is 1)
String [] currentAcceptedUsers = mat.getTaskInfo().getAcceptedByList();
int maxAllowed = mat.getMaxAllowedToAccept();
//empty out the accepted list and apply
mat.getTaskInfo().setAcceptedByList(new String[0]);
mat.applyChangesNoAccept();
//accept on behalf of the current user
mat.acceptTask();
}
Thanks for reply, i have done below code in initialise();,does below code give the solution what am expecting.
if (!getAccountClosureRequest().isCurrentUserAccepted()) {
String [] currentAcceptedUsers = getAccountClosureRequest().getTaskInfo().getAcceptedByList();
int maxAllowed = getAccountClosureRequest().getMaxAllowedToAccept();
if(currentAcceptedUsers.length==0&&maxAllowed==1)
{
//empty out the accepted list and apply
getAccountClosureRequest().getTaskInfo().setAcceptedByList(new String[0]);
getAccountClosureRequest().applyChangesNoAccept();
//accept on behalf of the current user
getAccountClosureRequest().acceptTask();
}
}
After i kept above logic in initialise method my obeservation is that in my left navigation portlet am calling flow service having publish and wait service for this am using AsyTree and Portlet simple link and extended portletURL control it will ope taskURL on center navigation.
if i click first time link, taskURL is opening in center and it is calling initialise() method and checking above logic and it is accepting the task by current user.
if i click same link second time initialise() method is not calling and opening task in center and accepted by is happening with current user.
i have check by putting logs in initiase method.
i have implemented same above logic in 3 tasks initialise methods and it has 3 links in left navigation.
if i click first time “A” task link,it is opening task in center navigation WITH ACCEPT BY CURRENT USER(calling initialise methods of that task).
than if i click B task link it is is opening task in center navigation WITH ACCEPT BY CURRENT USER(calling initialise methods of that task).
than if click again A" task link it is opening task in center navigation WITH ACCEPTED BY CURRENT USER(icalling initialise methods of that task).
Can you please explain me why initialise method is not if i click same task link morethan one-time.
Thanks for reply yesterday after i replied this topic i did same by keeping the logic in beforeRenderResponse() , my observations are it is working fine ever time it is doing auto accpet for every new task but in my task has asycommands and command buttons if i click these buttons every time it is calling beforeRenderResponse() method and checking the condition, will these cause perfomanace in QA and Production environment.
you replied that just add some flags as to whether you’ve already checked for the current taskID or not.i think it can achieve same if condition in my logic i.e if(currentAcceptedUsers.length==0&&maxAllowed==1)
{
And also in your reply you mentioned that “”“”“”“”““The initialize method is called when the the managedBean has been newly created. I think in the situations you describe where the initialize() method isn’t invoked is because that bean hasn’t been destroyed yet””“”“”“”“”',can you please reply me how to detroy the managedbean to call initialise method,now it is set with expireWithPageFlow “true” and managedbean scope session.