Issue with Accept Task smart service

Hello, I am struggling to use the "Accept Task" smart service. I don't have the expected behavior as detailed in the document. Any idea? Best regards Fabien...

BEBY_ACCEPT PB.docx

OriginalPostID-124074

OriginalPostID-124074

  Discussion posts and replies are publicly visible

  • Elizabeth, I did not know how to reach you so I added you as a participant. Hope this will work. Best regards
  • Fabien, The status is not wrong, Anytime there is a new instance created of the User Input task the status of that TASK changes to Assigned until accepted. the previous task will show as accepted,. You can see the numer of instances by right clicking on that particular node. Since you have a loop or may be a chained activity due to your logic a new task is created and task is assigned to the assigned user.
  • Hi Rayudua, thank for your answer. Actually I am aware of the mentionned behavior but there is a smart service called "Accept task" from the task service component that should change the task status from "Assigned" to "Accepted" but I struggle to make it work.
  • I'm not sure I understand the entire sequence of your model here or what you are trying to do, but I recommend trying to get "Accept Task" working once, and then seeing how it works in your loop. Upon running the Accept Task smart service (and passing in the correct ID), the task should be Accepted by the user whose context is running the Smart Service.
    If the task can't be accepted by the given user, it will return an errorOccurred and errorTxt parameter. Did you verify that the outputs of the service indicate success? And that you are passing in the correct Task ID? Since you are running it in a loop, each time the task is initiated, it will get a new ID.
  • Hello Elizabeth, thank you for your reply. My goal is to save intermediate user input values in a database without completing the task. I actually close the task and I create a new one that I try to have automatically accepted by the tp!owner of the first task. I get the correct ID using you custom getactivetaskiffromprocess function but I don't manage to have the task accepted (it does work only when I have sys admin rights). The process does not err as depicted in my document. You mentionned in your message "the task should be Accepted by the user whose context is running the Smart Service". Could you tell me more about the context? How should I change the context so that the tp!owner of the first task becomes the owner of the second? I have currently used chained tasks and put the smart node in a sub process, but it does not seem to work.
  • If it only works for sys admins, my guess is your "Accepting" user doesn't have permission to accept the task. As mentioned in my previous post, if you save the node outputs they might give you some information about what's happening.
    Some more information about Security Contexts can be found here: forum.appian.com/.../Designing_a_Process_Model.html

    But basically you can't specify an arbitrary user to accept the task if it's running unattended. It has to be the process initiator or designer. If you need to accept it as a different user, then you'd have to create a modified plugin with a user as an input. (And again, that user still needs to have permissions to accept the task. I.e. be in the original assignment pool, or a manager of the process.)

  • Thank you Lizzie. I will update my design and will see how it goes. I will keep you posted. Thanks again.
  • Elizabeth, from what I understand I need to find a way to declare the user as the pp!initiator and to grant him the relevant security rights to have the "accept task" work. It should be OK concerning the rights as I can change the user type to systemadmin the time for me to run the "accept task". The question is now: how can the user be the pp!initiator? I have tried different process designs without success and I am now looking at the API. Do you know if it would work if I use the "ProcessRoleMap" class and more precisely the "addinitiators" function?
  • a) I wouldn't make the user a Sys Admin just to accept the task. I'd make him or her a Manager (or higher) of the process instance.
    b) Right, this is getting into a complex / subtle area of how process security works. You can't "make" someone an initiator of a process, unless he actually initiated a process. If you are inclined to play with the APIs, I would recommend just creating a revised version of the Accept Task service, which takes in a username as an input, then accepts the task as that user. (You have to initiate ProcessExecutionService as that user context, in Java, instead of using the default Service Context that's passed into the node.)