Embedded form issue in usertask

Hi ,
I am referring same html(embedded:deployment:form.html) within startEvent and userTask .Starting an event with all the values .But the input values are not auto populated within UserTask.
Please find my html and BPMN are here.

Html:

 <label class="control-label" for="key">Key :</label>

 <div class="controls">

    <input id="key" class="form-control" type="text" ng-model="Object.key" required />

 </div>
....

BPMN:
<bpmn:startEvent id=“StartEvent_1” camunda:formKey=“embedded:deployment:form.html”>
bpmn:outgoingFlow_0v0j0dd</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id=“Flow_0v0j0dd” sourceRef=“StartEvent_1” targetRef=“Activity_06yhp3a” />
<bpmn:userTask id=“Activity_06yhp3a” camunda:formKey=“embedded:deployment:form.html”>

</bpmn:userTask>
<bpmn:endEvent id=“Event_1484ro2”>
bpmn:incomingFlow_16atbfz</bpmn:incoming>
</bpmn:endEvent>

Hey @keshavireddy_99!
I do have an exemplary embedded form right here on my GitHub:

Maybe this gives you a better idea how to populate variables.
This will be referenced in BPMN like this:

Let me know if you have any further questions or do not get it to work properly. :slight_smile:

1 Like

Hey Thanks alot , I am using ng-model as an attribute in input field , here in the example i could see you are using cam-variable-name=“Tweet” and binding that name in bpmn usertask (camunda:formField id=“Tweet”).

input type=“text” cam-variable-name=“Tweet”
input id=“key” class=“form-control” type=“text” ng-model=“Object.key” → If i use id to bind with usertask , I am not seeing data populated .

To be precise i want all the input fields populated during the start task , should be auto populated within usertask form and can be edited if needed , if user edits that should be reflected within json .

I think you really need to use the provided form controls to input parameters. Something like:

<input id="inputLoanAmount"
       required
       type="number"
       cam-variable-name="loanAmount"
       cam-variable-type="Double"
       min="1000" />

Right here there is also a good example. I would try it the exact same way.

Hey , github code which you shared they are using two different forms for startevent and usertask .In my case there will be same form data for both start event and usertasks which should be reviewed and edited by the reviewer if needed to.

In starttevent form i am creating a json and i m referring same html in usertasks , though the data is populated when starting a process ,in usertask form fields are empty …

The solution which is shared has two forms .
In my scenario too if i create two forms one for start event which creates json variable and other form to refer in usertask its working fine .That means though data and fields are same for both start and usertasks shall i have to create form for each task and read that as referred in the code which you shared??

I am referring this https://camunda.com/blog/2015/02/json-everywhere-how-to-use-json-in/ to create json in flow.

Hi @keshavireddy_99,

Following below post

And using a unified form for both, you can distinguish between start event and user task using below condition

if (camForm.taskId != null) {
// task form logic
} else {
// start form logic
}
2 Likes

Hey ,Thanks alot for the solution.

Within same html can i hide/show few elements ,for particular usertasks??
And any of the user reviews and changes the form values it should be reflected within json .Will that be possible with taskID filtering??

Hi @keshavireddy_9,

Yes, it should be possible.
I will share a simple form example later.

1 Like

Thanks alot for your time.

Hi @keshavireddy_99 ,

I created a simple process with a unified html form.
https://github.com/hassan-ghanem/camunda-forum-examples/tree/main/test-html-form-process

You can download, deploy from the modeler then test.

1 Like

Hi @hassang ,

Its giving 404 , can you plz check once if its uploaded properly??

Hi @keshavireddy_99,

Please try now

1 Like

That works , Thanks alot for the solution.