Textarea in embedded form

Hi,

I would like to use a WYSIWYG editor inside an embedded camunda form.
I load CKEDITOR and in order for the script to initialize the editor I need a text area with a closing tag, that is something like the following:
<textarea name="myField" id="editor" cam-variable-name="myField" cam-variable-type="String"></textarea>
When I use such a field in the page, the editor is initialized normally but the attribute is not submitted on form submit. I read in the forum that when using a textarea I should be using a self closing tag, that is something like the following:
<textarea name="myField" id="editor" cam-variable-name="myField" cam-variable-type="String"/>
In this case though, CKEDITOR refuses to initialize :slight_smile:

Do you have any suggested solution or example to this problem?

Thank you

Hi again,
I managed to find a workaround to this problem, that is to dynamically use js for creating a custom variable on submit. I am pasting the sample code below:

camForm.on('submit', function(evt) {
      var fieldValue = $('.ck-content').html();
	  var variableManager = camForm.variableManager;
      variableManager.createVariable({
       		 name: 'userComments',
       		 type: 'String',
        	 value: fieldValue,
       		 isDirty: true
      });

   });

But now I have stumbled upon another problem.The problem I am facing is the following:
I have a series of user tasks and in each task I need to show 2 areas in an embedded form. One for adding comments (that is where CKEDITOR mentioned above comes into play) and one for showing previous comments (added in previous tasks by other users).
For doing so I need to be able to store a large String with all the previous comments in some process variable to be able to show it. There is a limitation to 4000 chars though so I cannot do that.
To overcome this problem, I store a StringBuffer as the process variable (by using an end listener in each task)
I do not know how I can display this information in the UI though. If I try (through a start listener) to create a String process variable then this is also stored in the database. If I make it transient, then this is not available in the task’s embedded form.

Do you have any suggestions/example for this?

Thank you

Hi @Jagg,

please have a look into this example about Json variables in embedded task forms: camunda-bpm-examples/usertask/task-form-embedded-json-variables at master · camunda/camunda-bpm-examples · GitHub

Hope this helps, Ingo

Hi @Ingo_Richtsmeier

Thank you for the example. This was very helpful indeed. Unfortunately the problem is not solved though. I manage to pass the information back to the server inside a JSON object but the information cannot be persisted to the database. I get the attached error. As you will notice I try to save an attribute which is large.

error.txt (45.8 KB)
Do you have any suggestions?

Thank you

Hi again,
I managed to overcome this problem by just altering the database columns from Varchar(4000) to MediumText in MySQL.
Pasting here the queries in case they are helpful for anyone.

ALTER TABLE act_ru_variable MODIFY COLUMN TEXT_ MEDIUMTEXT;
ALTER TABLE act_ru_variable MODIFY COLUMN TEXT2_ MEDIUMTEXT;
ALTER TABLE act_hi_dec_in MODIFY TEXT_ MEDIUMTEXT;
ALTER TABLE act_hi_dec_in MODIFY TEXT2_ MEDIUMTEXT;
ALTER TABLE act_hi_dec_out MODIFY TEXT_ MEDIUMTEXT;
ALTER TABLE act_hi_dec_out MODIFY TEXT2_ MEDIUMTEXT;
ALTER TABLE act_hi_detail MODIFY TEXT_ MEDIUMTEXT;
ALTER TABLE act_hi_detail MODIFY TEXT2_ MEDIUMTEXT;
ALTER TABLE act_hi_varinst MODIFY TEXT_ MEDIUMTEXT;
ALTER TABLE act_hi_varinst MODIFY TEXT2_ MEDIUMTEXT;

I would like to ask if there is any reason to avoid the above alterations.
So far (working in local dev not prod) I have not had any problems.

Thank you

@Jagg Consider the scenario like where further version upgrades required scripts like create/update index or alter script on these tables will affect due to type mismatch (TEXT_ to MEDIUMTEXT_). You need to manage it every time manually.

Storing as Object format (byte array) doesn’t help to solve this problem?

Hi @aravindhrs

Thank you for the prompt feedback.
The last time I tried I got the same error as before. If you open the file I attached previously you will see the Json object that I was attempting to persist in the database.
I will give it another try (maybe I had some mistake somewhere) and write to you again.

Thank you