Same tasks are getting assigned to the multiple users when trigeered at the same time

Certified Senior Developer

Same tasks are getting assugned to the multiple user

We are using Appian version 22.3

We have the lists of tasks available for picked-up from task pool.
On a click of button GetNext, same tasks are getting assigned for the multiple users if click on the same exact time .

Can someone guide us for the resolution .

Thanks !!

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    What does this GenNext button do exactly?

  • 0
    Certified Lead Developer

    Yes, we might be able to do that, when you provide a lot more details about what is going on.

  • 0
    Certified Senior Developer
    in reply to Mathieu Drouin

    GetNext button start the process that will query the task from Task table then assign the task to who click the GetNext first. We are assigning the task based on the active process instances which we are getting from the Process analytical report. If multiple users are clicking on the same time then the same task is being assign to the multiple users. 

  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    GetNext button start the process that will query the task from Task table then assign the task to who click the GetNext first. We are assigning the task based on the active process instances which we are getting from the Process analytical report. If multiple users are clicking on the same time then the same task is being assign to the multiple users. 

  • 0
    Certified Lead Developer
    in reply to sinushreeb

    Not sure why you are you doing it this way?

    Why not assign it to a group and let the appropriate user accept the task?

  • 0
    Certified Lead Developer
    in reply to sinushreeb

    That is to be expected. When two simultaneous processes query the same table, they will get the same result which leads to the situation you observe. This is called a race-condition.

    We might be able to come up with an alternative approach in case you can share even more details about the goal, solution, design and architecture of this application.

  • 0
    Certified Senior Developer
    in reply to Mathieu Drouin

    Goal is to assign task based on the user Profile (Team,location,etc)

    Task details is being saved in DB ;assigned to correct Team, pick up date,location and prefered language and etc)

    (TaskId, Team,PickUpdate,Location,PrimaryLanguage,SecondaryLanguage,Product, State Code Priotity)

    Assuming Team A has 5 team member with the same user set up(Team,location,etc) starting(click button) to get a task at the same time,
    but there are only 3 task available in DB for pick up.

    Current Solution is we have implemented a process report to identify which started the first.
    Each process query available task(1st task), then we query the process report for the first intance.
    Once we found the first intance task is assigned to the person who started it.


    if(
    or(
    a!isNullOrEmpty(ri!initialTaskId),
    a!isNullOrEmpty(ri!instanceId)
    ),
    null,
    a!localVariables(
    local!data: a!queryProcessAnalytics(
    report: cons!HRC_PROCESSREPORT_GETNEXTDOUBLEASSIGNMENT,
    contextProcessModels: cons!HRC_PM_SET_NEW_TASK,
    query: a!query(
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: {
    a!queryFilter(
    operator: "=",
    field: "c7",
    value: ri!initialTaskId
    ),
    a!queryFilter(
    operator: "between",
    field: "c2",
    value: {
    subtractminutes(now(), 2),
    todatetime(now())
    }
    )
    }
    ),
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 20,
    sort: a!sortInfo(field: "c4", ascending: true())
    )
    )
    ),
    local!firstUser: tostring(
    index(
    (
    index(
    index(local!data, "data", null),
    "c6",
    null
    )
    ),
    1,
    null
    )
    ),
    local!firstInstance: tostring(
    index(
    (
    index(
    index(local!data, "data", null),
    "c4",
    null
    )
    ),
    1,
    null
    )
    ),
    local!hasmutipleIntance: local!data.totalCount > 1,
    a!map(
    hasMultipleInstance: local!hasmutipleIntance,
    firstUser: local!firstUser,
    isFirst: local!firstInstance = ri!instanceId,
    instanceId: local!firstInstance,

    )
    )
    )

  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    Goal is to assign task based on the user Profile (Team,location,etc)

    Task details is being saved in DB ;assigned to correct Team, pick up date,location and prefered language and etc)

    (TaskId, Team,PickUpdate,Location,PrimaryLanguage,SecondaryLanguage,Product, State Code Priotity)

    Assuming Team A has 5 team member with the same user set up(Team,location,etc) starting(click button) to get a task at the same time,
    but there are only 3 task available in DB for pick up.

    Current Solution is we have implemented a process report to identify which started the first.
    Each process query available task(1st task), then we query the process report for the first intance.
    Once we found the first intance task is assigned to the person who started it.


    if(
    or(
    a!isNullOrEmpty(ri!initialTaskId),
    a!isNullOrEmpty(ri!instanceId)
    ),
    null,
    a!localVariables(
    local!data: a!queryProcessAnalytics(
    report: cons!HRC_PROCESSREPORT_GETNEXTDOUBLEASSIGNMENT,
    contextProcessModels: cons!HRC_PM_SET_NEW_TASK,
    query: a!query(
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: {
    a!queryFilter(
    operator: "=",
    field: "c7",
    value: ri!initialTaskId
    ),
    a!queryFilter(
    operator: "between",
    field: "c2",
    value: {
    subtractminutes(now(), 2),
    todatetime(now())
    }
    )
    }
    ),
    pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 20,
    sort: a!sortInfo(field: "c4", ascending: true())
    )
    )
    ),
    local!firstUser: tostring(
    index(
    (
    index(
    index(local!data, "data", null),
    "c6",
    null
    )
    ),
    1,
    null
    )
    ),
    local!firstInstance: tostring(
    index(
    (
    index(
    index(local!data, "data", null),
    "c4",
    null
    )
    ),
    1,
    null
    )
    ),
    local!hasmutipleIntance: local!data.totalCount > 1,
    a!map(
    hasMultipleInstance: local!hasmutipleIntance,
    firstUser: local!firstUser,
    isFirst: local!firstInstance = ri!instanceId,
    instanceId: local!firstInstance,

    )
    )
    )