Solution for Initiating Processes or Writing Data on Task Acceptance

Certified Lead Developer

For many years, Appian designers have been unable to easily log data upon the acceptance of a task (when a user clicks "Accept"). Whenever the business asks for this, whether for task metrics, or updating statuses, or any other reason, we usually tell them it's impossible or come up with mediocre workaround using a splash screen with a custom task assignment / acceptance. If only Appian could expose a saveInto for the Accept button... 

I recently finished implementing an approach that allows designers to start any process or write any record upon acceptance. If anyone's interested or has a similar use case, please comment below and perhaps try to guess the solution. Hint: use an integration call in a local variable to start a process model or a!writeRecords. The tricky part is determining the moment a task is accepted. This is different for tasks assigned to groups vs tasks assigned to individual users.

If there's interest, I'll post the solution after I return from vacation

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Glad to see there's interest! This is the solution I used, although this does not support the Reassign Task smart service. 

    a!localVariables(
      /*Original owner of the task - pass tp!owner from User Input Task*/
      local!ownerAtLoad: a!refreshVariable(
        refreshOnReferencedVarChange: false,
        value: ri!owner
      ),
      
      /*Is task already accepted? If owner exists on load, then yes*/
      local!isAlreadyAccepted: a!isNotNullOrEmpty(local!ownerAtLoad),
      
      /*Did the task acceptance occured just now (For group assignment, on "Accept" click. For individual assignemnt, on task open)*/
      local!isAcceptanceAction: if(
        local!isAlreadyAccepted,
        false,
        if(
          /*Determine whether task is assigned to individual*/
          and(
            length(ri!assignees)=1,
            length(touser(ri!assignees))=1
          ),
          /*Assigned to individual - task acceptance occurs when buttonValue is blank (handles chained looping in process model) and loggedinuser is assignee*/
          and(
            a!isNullOrEmpty(ri!buttonValue),
            loggedinuser()=touser(ri!assignees)
          ),
          /*Assigned to group - task acceptance occurs if task was not already accepted and ri!owner is not null ("Accept" was clicked)*/
          and(
            not(local!isAlreadyAccepted),
            /*If accept is clicked, ri!owner gets reloaded with the current tp!owner*/
            a!isNotNullOrEmpty(ri!owner)
          )
        )
      ),
      /*If task acceptance occurs, then call API to execute processes or write records*/
      if(
        local!isAcceptanceAction,
        <execute>,
        null
      )
    )

Reply
  • 0
    Certified Lead Developer

    Glad to see there's interest! This is the solution I used, although this does not support the Reassign Task smart service. 

    a!localVariables(
      /*Original owner of the task - pass tp!owner from User Input Task*/
      local!ownerAtLoad: a!refreshVariable(
        refreshOnReferencedVarChange: false,
        value: ri!owner
      ),
      
      /*Is task already accepted? If owner exists on load, then yes*/
      local!isAlreadyAccepted: a!isNotNullOrEmpty(local!ownerAtLoad),
      
      /*Did the task acceptance occured just now (For group assignment, on "Accept" click. For individual assignemnt, on task open)*/
      local!isAcceptanceAction: if(
        local!isAlreadyAccepted,
        false,
        if(
          /*Determine whether task is assigned to individual*/
          and(
            length(ri!assignees)=1,
            length(touser(ri!assignees))=1
          ),
          /*Assigned to individual - task acceptance occurs when buttonValue is blank (handles chained looping in process model) and loggedinuser is assignee*/
          and(
            a!isNullOrEmpty(ri!buttonValue),
            loggedinuser()=touser(ri!assignees)
          ),
          /*Assigned to group - task acceptance occurs if task was not already accepted and ri!owner is not null ("Accept" was clicked)*/
          and(
            not(local!isAlreadyAccepted),
            /*If accept is clicked, ri!owner gets reloaded with the current tp!owner*/
            a!isNotNullOrEmpty(ri!owner)
          )
        )
      ),
      /*If task acceptance occurs, then call API to execute processes or write records*/
      if(
        local!isAcceptanceAction,
        <execute>,
        null
      )
    )

Children