define expression in camunda - camunda

I have a process that has a custom model, similar to the following model(get by calling http://localhost:8080/engine-rest/task/{id}/variables/):
{
"Title": {
"type": "String",
"value": "aaa",
"valueInfo": {
}
},
"247f3af4-36cf-72cc-1a95-601f07640674": {
"type": "String",
"value": "{\"Title\":\"AA\",\"Value\":\"BB\"}",
"valueInfo": {
}
}
}
I want to define a expressions at the gates. How should I do this?
I try these:
${ "247f3af4-36cf-72cc-1a95-601f07640674".Value == "AA"}
Or
${ JSON("247f3af4-36cf-72cc-1a95-601f07640674").prop("Value") == "AA"}
Or
${S(247f3af4-36cf-72cc-1a95-601f07640674).prop("Value").stringValue() == "AA"}
But get following errors:
Unknown property used in expression: ${ "247f3af4-36cf-72cc-1a95-601f07640674".Value == "AA"}. Cause: Could not find property Value in class java.lang.String
Error while evaluating expression: ${ JSON("247f3af4-36cf-72cc-1a95-601f07640674").prop("Value") == "AA"}. Cause: Error invoking function 'JSON'
ENGINE-01009 Error while parsing process. Error parsing '${S(247f3af4-36cf-72cc-1a95-601f07640674).prop("Value").stringValue() == "AA"}': syntax error at position 15, encountered 'c7', expected ')'.

What you are showing is the value of a JSON object stored in a process data, right? What is the name of the process data?
In Java you use JSON(), in the process (JavaScript) use S()
(see https://docs.camunda.org/manual/7.17/reference/spin/json/01-reading-json/)
Place S() around the name of your process data to create the object. Then you can use .prop() to navigate it. ${S(myData).prop("xyz")}.
In this example I used the method to read the JSON response of a REST call and then extract a field:
https://github.com/rob2universe/camunda-http-connector-example
You use JSON() around the name of the process data, then you can access the properties

I finally find answer
I must use something like this:
${S(a247f3af4_36cf_72cc_1a95_601f07640674).prop("Value").stringValue() == "AA"}
we must start variable name with character and do'nt use -.

Related

How to get "paymentToken" value using Reg Exp Extractor in Jmeter?

My Response Code Looks like: -
{
"data": {
"transactionId": "04dxf19-xx-42e3-a4f7-75xxa012x4a",
"paymentUrl": "https://wpp-test.wirecard.com/?wPaymentToken=t45QiNvkZX5fYxxxxEEpFz8mcK2ZirBhVMrvuo"
},
"message": "Success.",
"code": "OK",
"appVersion": "2.0.0.47",
"machine": "CHPV345678"
}
and from the above code, I want to extract the value inside = wPaymentToken ( i.e t45QiNvkZX5fYxxxxEEpFz8mcK2ZirBhVMrvuo)
I tried the following options without success -
1) "paymentUrl":
"https://wpp-test.wirecard.com/?wPaymentToken=(.+?)"
2)
wPaymentToken=(.+?)"
Can you please help me , as while checking the value in Debug Sampler it always remains enmpty
Here Is my Test Plan : It contains two REGEX in 1 thread
Here is the reson , why I only want paymentToken because Final URL is not same as the URL that we extracted using JSON
Second option should work fine:
Wouldn't be easier to extract the whole paymentUrl attribute value? It can be done using JSON Extractor with a simple JsonPath expression of $.data.paymentUrl

How to check the type of a field before checking the value in rethinkdb?

I have few tables in rethinkdb with very varied datasets. Mostly because over time, out of simple string properties complex objects were created to be more expressive.
When I run a query, I'm making sure that all fields exist, with the hasFields - function. But what if I want to run a RegExp query on my Message property, which can be of type string or object. Of course if it is an object, I don't care about the row, but instead of ignoring it, rethinkdb throws the error:
Unhandled rejection RqlRuntimeError: Expected type STRING but found OBJECT in...
Can I somehow use typeOf to first determine the type, before running the query?
Or what would be a good way to do this?
Your question is not 100% clear to me so I'm going to restate the problem to make sure my solution gets sense.
Problem
Get all documents where the message property is of type object or the message property is a string and matches a particular regular expression (using the match method).
Solution
You basically need an if statement. For that, you can use the r.branch to 'branch' your conditions depending on these things.
Here's a very long, but clear example on how to do this:
Let's say you have these documents and you want all documents where the message property is an object or a string that has the substring 'string'. The documents look like this:
{
"id": "a1a17705-e7b0-4c84-b9d5-8a51f4599eeb" ,
"message": "invalid"
}, {
"id": "efa3e26f-2083-4066-93ac-227697476f75" ,
"message": "this is a string"
}, {
"id": "80f55c96-1960-4c38-9810-a76aef60d678" ,
"not_messages": "hello"
}, {
"id": "d59d4e9b-f1dd-4d23-a3ef-f984c2361226" ,
"message": {
"exists": true ,
"text": "this is a string"
}
}
For that , you can use the following query:
r.table('messages')
.hasFields('message') // only get document with the `message` property
.filter(function (row) {
return r.branch( // Check if it's an object
row('message').typeOf().eq('OBJECT'), // return true if it's an object
true,
r.branch( // Check if it's a string
row('message').typeOf().eq('STRING'),
r.branch( // Only return true if the `message` property ...
row('message').match('string'), // has the substring `string`
true,
false // return `false` if it's a string but doesn't match our regex
),
false // return `false` if it's neither a string or an object
)
)
})
Again this query is long and could be written a lot more elegantly, but it explains the use of branch very clearly.
A shorter way of writing this query is this:
r.table('messages')
.hasFields('message')
.filter(function (row) {
return
row('message').typeOf().eq('OBJECT')
.or(
row('message').typeOf().eq('STRING').and(row('message').match('string'))
)
})
This basically uses the and and or methods instead of branch.
This query will return you all registers on table message that have the field message and the field is String.
Cheers.
r.db('test').table('message').hasFields('message')
.filter(function (row) {
return row('message').typeOf().eq('STRING')
})

AWS DynamoDB Scan filterExpression - simple number comparison

I am trying to do a simple dynamoDB scan with a filter expression (documentation here)
This is my expression string:
"attribute_exists("my_db_key") AND ("my_db_key" = 1)"
This simply states:
"If a value for my_db_key exists AND my_db_key EQUALS 1, return it in the results"
However it does not work and I get a this error:
Invalid FilterExpression: Syntax error; token: "1", near: "= 1)
I am aware that I can use an attribute value placeholder for values and then use that in the expression but I do not want to do this. And according to Amazon's documentation it is NOT required.
So how do I do this simple expression? Does anyone have an example or link to documentation? Amazon's documentation is unfortunately of no help.
NOTE: I am implementing this with AWSDynamoDBScanInput on iOS but my issue here is to do with global expression syntax so it should not matter.
Your params need to look something like this (for the Node AWS library):
params = {
"FilterExpression": 'attribute_exists("my_db_key") AND ("my_db_key" = :value)',
"ExpressionAttributeValues": {
":value": 1
},
// ...
};
docClient.scan(params, function(err, data){
// Handle err or process data
})
For some languages, the parameters should look more like this:
{
"FilterExpression": 'attribute_exists("my_db_key") AND ("my_db_key" = :value)',
"ExpressionAttributeValues": {
":value": {"N":1}
},
// ...
};
You have to use a placeholder and pass the value separately. Here's some documentation and a Post from AWS forums

regular expressions: in a JSON array, get the id of the object that has status waiting

I have a JSON response that I want to parse with regular expressions that contains an array of objects like
...
{
"Id":"01",
"Subject":"Sub",
....
"Status":"Completed"
...
},
{
"Id":"02",
"Subject":"Sub",
....
"Status":"Waiting"
...
}
and I want to get the id of the object that has status waiting.
When I parse with "Id": "(.+?)",[\s\S]+?"Subject": "Sub",[\s\S]+?"Status": "Waiting"; it matches from "Waiting" to the first "Id" (backwards); certainly I want the Id of the object that is waiting.
Try this:
{\s*"Id":"(\d+)"[^}]+"Status":"Waiting"\s*}
Try this one:
(?s)"Id":\s*"([^"]+)[^}]*?"Status":\s*"Waiting"
It will work if there is no nested { } between properties Id and Status.
If you can use a Json Parser, please use that.
This will work as long as there are no nested brackets.
{[^{}]*Id":"(\d+)[^{}]*\s"Status":"Waiting"
See it here on Regexr
Your expression
"Id": "(.+?)",[\s\S]+?"Subject": "Sub",[\s\S]+?"Status": "Waiting"
^^^^^^^^
fails here
That part matches anything from the first "Sub", till it finds the first "Status": "Waiting"

jqgrid dropdown select editoptions

I am trying to use the edittype:"select", formatter:"select" and editoptions:{values:'1:Type1;2:Type2'} in my colModel
colModel : [
{name:'pk', index:'pk', width:20, sortable:true, jsonmap:'pk',
sorttype:'integer'},
{name:'id', index:'id', align:'left', jsonmap:'fields.id',
sortable:true, editable:true, edittype:'select', formatter:'select',
editoptions:{value:'1:value1;2:value2;3:value3'},
{name:'type', index:'type', width:100,align:'center',
jsonmap:'fields.type', sortable:true,editable:true}
]
but the value for id returned in the json object is not a string (it doesn't have quotes around it). If I remove the edittype and editoptions the id value appears in the column of the grid but when I include the edittype, formatter and editoptions in the colMode definition I get the javascript error
(E||"").replace is not a function
The json object that fails looks like
{ "pk": 120
"model": "myModel"
"fields": {
"id": 1,
"type": "aType"
}
}
The id value has no quotes.
I am using the edittype, formatter and editoptions in other grids but the value I am macthing against is a character (in the json object it is surrounded by quotes) and it works perfectly.
I am only guessing that the problem is with the unquoted number but I am not sure. Has anyone seen this before?
Regards
Andrew
Ok,
I found that the problm is on line 1067 of the jquery.1.3.2 file. It is the trim function and the code looks like this:
trim:function(text) {
return (text||"").replace(/^\s+|\s+$/g, "")
}
I changed it to this:
trim:function(E) {
return (text.toString()||"").replace(/^\s+|\s+$/g, "")
}
and now it works.
Can anyone tellme if this is a bug or is there something else I can do to overide ths function without changing the jquery file.
Function Override: Placed in the head of any page that shows this problem.
$.extend({
trim:function(E) {
return (text.toString()||"").replace(/^\s+|\s+$/g, "")
}
});
Thanks
Andrew