Can't Filter Task History by Process Variable using "like" operator

Posting to the /history/task endpoint via the Rest API does not seem to work when trying to filter tasks by process variables using the operator “like”. Example POST body:

{
	"processVariables":[
		{
			"name": "firstName",
			"value": "Bob%",
			"operator": "like"
		}
	]
}

The response is

{
    "type": "InvalidRequestException",
    "message": "Invalid variable comparator specified: like"
}

According to the Rest API documentation (Get Tasks (Historic) (POST) | docs.camunda.org), this operator is allowed, but it doesn’t seem to be valid.

“processVariables: Valid operator values are: eq - equal to; neq - not equal to; gt - greater than; gteq - greater than or equal to; lt - lower than; lteq - lower than or equal to; like.”

The operator “eq” does work, but none of the other operators seem to work (all with the same response)

This seems like a bug. Are there any known workarounds for this issue?

I’m not sure you’ll consider this a “workaround”, but you can just go directly to the database. In our case we use MySQL, that’s what the following will address. We’re using Camunda 7.6.2. Assume the back end Camunda database is called “camunda”. You can adjust the columns returned as needed.

These statements apply to variables stored in the TEXT_ column of the database.

This will get you historical variables:

SELECT * FROM camunda.ACT_HI_VARINST WHERE NAME_ LIKE 'Bob%';

If you want runtime (running processes) variables, use this:

SELECT * FROM camunda.ACT_RU_VARIABLE WHERE NAME_ LIKE 'Bob%';

These statements apply variables stored in the ACT_GE_BYTEARRAY table. These variables are generally objects or over 4000 characters.

This will get you historical variable values and process instance IDs (adjust columns returned as needed):

SELECT
    ACT_GE_BYTEARRAY.NAME_
    , ACT_GE_BYTEARRAY.BYTES_
    , ACT_HI_VARINST.PROC_INST_ID_
FROM
    camunda_db.ACT_HI_VARINST
    INNER JOIN camunda_db.ACT_GE_BYTEARRAY 
        ON (ACT_RU_VARIABLE.BYTEARRAY_ID_ = ACT_GE_BYTEARRAY.ID_)
WHERE (ACT_GE_BYTEARRAY.NAME_ LIKE 'Bob%');

This will get you running process variables:

SELECT
    ACT_GE_BYTEARRAY.NAME_
    , ACT_GE_BYTEARRAY.BYTES_
    , ACT_RU_VARIABLE.PROC_INST_ID_
FROM
    camunda_db.ACT_RU_VARIABLE
    INNER JOIN camunda_db.ACT_GE_BYTEARRAY 
        ON (ACT_RU_VARIABLE.BYTEARRAY_ID_ = ACT_GE_BYTEARRAY.ID_)
WHERE (ACT_GE_BYTEARRAY.NAME_ LIKE 'Bob%');

Hope this helps.

Michael

Hi @Hilary_Mulholland,

I have checked the codebase and like operator is in reality not supported in this REST API call, as well as all others, apart from eq. Underlying API also does not have methods providing support for other operators. I think this is a copy-paste issue of documentation. If you want, you can contribute a pull request with adjustment of documentation.

Cheers,
Askar.

Hi @mppfor_manu,
Thank you so much for your response! I will use your advice and query the database directly!
Best,
Hilary

Dear developer, does this problem still exist in the latest version?
Thank you!

Was this fixed in earlier releases?