Is there a way to store (local) variables as BLOB from javascript

Hi,
writing execution or task listener in javascript the method setVariable(Local) stores strings as TEXTVAR in h2 database (which is limited to 4000kb). Is there a way (a method) to store (local) variables as BLOB from javascript (not using java!)

Thanks forward …

setu

You can store the value as a typed object which stores it as a blob. https://groups.google.com/forum/m/#!topic/camunda-bpm-users/SEfASvRC65k

A quick way would be to store as json type with camunda SPIN or create a small Java object to use

1 Like

Hi Stephen,

thanks for your response, but with javascript the object “Variables” is unknown!

Cheers
setu

Hi setu,

Use the full qualified class name org.camunda.bpm.engine.variable.Variables or import it via Java.type (see this tutorial: http://winterbe.com/posts/2014/04/05/java8-nashorn-tutorial/).

Cheers,
Thorben

Hi Thorben,

thanks a lot,… That is what I’ve been looking for. For all other users who have the same problem, here the complete solution storing value greater than 4000KB on javascript level:

setVariableLocalAsBlob = function(name,blob)
{
	var value = Java.type('org.camunda.bpm.engine.variable.Variables')
		.objectValue(blob)
		.serializationDataFormat(Variables.SerializationDataFormats.JAVA)
		.create();
	task.setVariableLocal(name,value);
}; 

Cheers
setu

3 Likes

Thanks for sharing the solution :slight_smile: