class HelloWorldFlow(Flow):
process_class = HelloWorldProcess
######### Here I start the process where i enter some text
start = (
flow.Start(CreateProcessView, fields=["text"])
.Permission(auto_create=True)
.Next(this.approve)
)
######### Here i update the process view with the user name which i obtained from "asignedto"- which consist of all the user in a drop down
approve = (
flow.View(UpdateProcessView, fields=["asignedto"])
.Assign(lambda act: act.process.created_by)
.Permission(auto_create=True)
.Next(this.task_assign)
)
######### Below is the code where i am facing difficulty i am not able to know how to pass the user name in the .Assign()
######### This one works .Assign(username="Debasish"), however i want to assign the user based on previous workflow which is approve, where i selected from the drop down
######### This one do not work .Assign(username=this.approve.owner)
task_assign = (
flow.View(AssignTaskView)
.Assign(this.approve.owner)
.Next(this.check_approve)
)
######### Below this its working
check_approve = (
flow.If(lambda activation: activation.process.approved)
.Then(this.send)
.Else(this.end)
)
send = flow.Handler(this.send_hello_world_request).Next(this.end)
end = flow.End()
def send_hello_world_request(self, activation):
print(activation.process.text)
How to Assign a Task to a user in Django-Vieflow
619 Views Asked by Debasish Behera At
1
One of the advantages of the BPMN is the process traceability. You can't implement a process that would not persist the process decisions. That's very handy for the process performance analytics.
Each task in the BPMN is independent of each other and could perform decisions on a process data only. That gives flexibility to a flow diagram and allows to rearrange flow nodes since there is only data storage dependency between them.
So, the short answer - store a user in the Process model and use
.Assign(lambda act: act.process.granted_user_for_a_task)