Django Viewflow - Passing field values via urls upon process start
Is it possible **, to pass a value to a process via the startup url/path.
I have a process model with a note
field.
I want to start a new process flow and pass the note to the url e.g.
http://server.com/my_process/start/?note=mynote
Since Viewflow is a thin workflow layer built on top of Django, URL parameter processing works just like in Django. Parameters are available in the request.GET object, and you can use them in a custom view according to your needs.
For example, to pre-initialize a user form with a value from the URL, you can create a custom subclass of CreateProcessView:
from viewflow.workflow.flow.views import CreateProcessView
class CustomCreateProcessView(CreateProcessView):
"""
Custom view to initialize a process with data from the request URL.
"""
def get_initial(self):
initial = super().get_initial()
initial['text'] = self.request.GET.get('note', '')
return initial
With this approach, when you navigate to a URL like http://server.com/my_process/start/?note=mynote, the note parameter will be extracted and used to initialize the text field in the form.
For more details, refer to the Django documentation on class-based views and URL handling.