how to get variable value from liquid in elsa workflow? - elsa-workflows

I'm trying to get a variable's value from liquid in Elsa workflow but it's not working,
it just shows the variable's name in c# code.

The value you are showing in your screenshot is correct: the Body property provides you with the unparsed contents.
To get the parsed content, use the expressionEvaluator service you have there in your OnExecuteAsync method. Which you already do: just make sure to inspect (and use) the body variable.

Related

Jmeter check using if controller, for a variable has a value or not

in one of my steps in the Jmeter script, I'm using json extractor to read a value from a key(address) in the JSON response and store it in a variable called "TypeOfRequest." In the next step, I need to check if the "TypeOfRequest" value is null or not(There can be situations I don't find that key in the JSON response). Then I need to take a different route.
Snippet how I'm getting the TypeOfRequest from Json extractor $.communicationMethods[:1].hTTPS.address
So my question is, how do I check if TypeOfRequest has a value or not in the if controller?
tried using '${__javaScript(vars.get("TypeOfRequest") == null)}(ref https://www.blazemeter.com/blog/jmeter-if-controller and https://sqa.stackexchange.com/questions/32969/how-do-i-check-if-a-variable-is-null-using-a-if-controller) but unable to go through the if condition, can someone help me with this. Thanks in advance
Just use Debug Sampler to see what JMeter Variables are defined and inspect their values, my expectation is that you're "unable to go through the if condition" because your TypeOfRequest variable is not null, i.e. it's present but it's an empty string.
Also the referenced article suggests using __groovy() or __jexl3() function so I believe if you change your condition to something like:
${__groovy(org.apache.commons.lang.StringUtils.isEmpty(vars.get('TypeOfRequest')),)}
you will be able to "go through the if condition"

In Freemarker, how can I access custom attributes in a template file?

In a Freemarker template file, how can I access properties set using the freemarker.core.Configurable#setCustomAttribute(java.lang.String, java.lang.Object) method on a Template instance?
Or if this is not possible, how can I push some variables into the template before processing the payload, that I can access within the template file?
Cheers,
Kai
Custom attributes are for propagating the values in the opposite direction. You can't get custom attributes in templates, you can only set them there, in the #ftl header. For example, a template could specify the MIME type of its output there, and then what calls the template can set the content type of the HTTP response based on that.
If you have a data-model that's not specific to the template you call, and you need to pass some extra variables only to that template, that's a problem to solve on the data-model level. Like you could compose a new data-model with TemplateModelUtils.wrapAsHashUnion(ObjectWrapper, java.util.List<?>), and pass that to the template.
Alternatively, you can get the Template as usual, but then create its runtime environment with Template.createProcessingEnvironment, set the variables in the Environment, and then call Environment.process(). That's like calling some #assign-s from outside the template, before you actually start running the template.

Unable to send object value in next request json body

I am trying to send object value based on condition to the previous request.
From above,pricecheck i will get formtype value based on form type validation i have to send guests info in request..
here i am able to validate but not able to pass the object value if i try any string i can able to do,please help me.
You need to put a string value in vars, surrounded with quotes " and escape inner quotes\",as
vars.put("guests", "{ \"title\":\"Mr\", .... }");
You're violating 2 major best practices:
You're referring JMeter Variables like ${form} in the JSR223 Test Elements while you should be using vars.get('form') construction instead
You're using JavaScript language which is a performance anti-pattern, since JMeter 3.1 you should be using Groovy language for scripting
Check out Parsing and producing JSON article to learn more about reading and generating JSON in Groovy.
Also posting code in form of screenshots is not something you should be doing otherwise the chance of getting a comprehensive answer will be much less

Fetch the value of variable inside variable in jmeter

In the JSR Sampler I am assigning the value of a String I create i.e., SFDC_Prouct_1 in list. for e.g.,
list=SFDCProduct_5
Here SFDCProduct_5 is already a variable which has XML elements. Now I am trying to place a http request and in the payload I want to inject the value of SFDCProduct_5 . But I have to write ${list}, as list has the value of SFDCProduct_5 .
I tried ${${list}}, but thats not working.
Any ideas?
In JSR223 Sampler you can get the nested variable using vars.get
vars.get(vars.get("list"));
If I correctly understood your question you need to wrap your ${list} into __eval() function like
${__eval(${list})}
Demo:
See Here’s What to Do to Combine Multiple JMeter Variables article for more information if needed.

How to use response field in a new request in Jmeter

I have this issue that I want to solve.
I want to create a new http request using field from previous response
I send a request
I used Json extractor to move the response string to a variable (let call this string nurl)
I used Regular expression and move the field that I want to "Reference Name"
(meanning from nurl I just want tt_cid)
Now I want to make a new call, and use that field tt_cid in my new call
How I shall call tt_cid? since it is not passed as User Defined Variables,
when I use tt_cid, I do not think J meter know it, since it is not written there, I just pulled it from the response.
Provided a Pic of what I have done
Regards to you all
Short answer call it ${tt_cid}.
since it is not passed as User Defined Variables, when I use tt_cid,
I do not think J meter know it,
For your understanding add Debug Sampler after Regular expression,
You will see all your JMeter variables, including tt_cid, which can be called as other variables ${tt_cid} inside other Samplers.
It's called Reference Name and not Variable Name because it's more complicated, You should read JMeter's Regular Expression to understand how it works internally, But basically it saves more than just 1 Variable.

Resources