How can you reference a single output from an if else conditional in Azure Logic Apps - azure-logic-apps

I have an Azure Logic app with an if/else conditional. In each branch I have a compose action to create some JSON. The true branch has compose and the false compose_2. After the conditional I want to send a message to a queue with the output from either branch but how do I reference the output? I have two actions("compose") and actions("compose_2"). Is there any way I can reference the output with a single variable/property name?

It is possible by using #result() which will return all the output of a scope (Condition in your case) as an array, and you can use #coalesce to find out the non-empty value between Compose and Compose_2.
However, I would use variable instead:
Declare an variable before Condition
Set the variable in each branch
Reference the variable after Condition

Related

Sending muliple occurrences of id to a request in jmeter

From a soap XML response I need to get all the occurrences of an id (This part already done using Match No being set to -1 in Regex extractor).
And then I need to send these ids to a subsequent request. That is, the request needs to be fired as many times as of the total number of occurrences of the id, we can call it as ID_matchNr. (This is the total occurrences I got from the Regex extractor).
I used a while loop and a counter. The while loop works until the ID_matchNr, but it doesn't stop there, that while loop is infinite. How to fix this?
My counter's reference name is count and the field name in my request is ${__V(ID_${count})}. And while loop's condition is ${count}<=${ID_matchNr}. I also tried using a beanshell to save the ID_matchNr to another variable and then use it in while condition instead of directly using ID_matchNr. Still running infinitely.
Have you considered using ForEach Controller?
Given you have JMeter Variables in form of:
ID_1=foo
ID_2=bar
ID_3=baz
ID_matchNr=3
Add ForEach Controller to your Test Plan and configure it like:
And put the "subsequent" sampler as a child of the ForEach Controller and refer the generated subsequent ID value as ${CURRENT_ID} where required
More information on the concept with the real-life example: Using Regular Expressions in JMeter

SSIS: Conditional Split result to variable

I have condition where I need to feed conditional split result based on condition (will be just one int value) to variable. Can some one help how to do this?
My actual package (Data flow):
XML Source --> Conditional split (based on condition) 2 outputs..one result based on condition (will be just one int value) need to pass it on to variable. How to achieve this?
Pure SSIS way - consume your dataflow into a Recordset Destination and then iterate through it with ForEach Loop, assigning value to the desired variable.
you have to use a script component to achieve this:
Create a script component (Choose it's type as Destination)
Double click on script component and Choose your Variable as a ReadWrite Variable. (in my example the variable is named Result
Inside the script window write the following code
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
If Not Row.inColumn_IsNull Then
Variables.Result = Row.inColumn
End If
End Sub
Side Note: Variable value does not change before dataflowtask execution is finish, to use the new value you have to continue your work in another dataflowtask
I know two ways to realize this.
First: Do it with a C# script component, this is the easiest way.
Just put a script component behind your conditional split, select your variable as "ReadWrite", then set it like that in the code:
Dts.Variables["yourvariable"].Value = Input0Buffer.Yourcolumn
I don't have access to SSIS right now, so I can't give you the exact code, but this should get you started.
Second: Write to a table and read it back with Execute SQL task. I don't really like this way ;-)

Test action outputs length

In my Logic App workflow, I'm trying to evaluate a condition for the previous action outputs array.
My condition expression
#less(action('Get_items').outputs.length, 1)
results in error
action 'Item_found' completed with status 'Failed' and code 'BadRequest'.
The same happens for
#greater(action('Get_items').outputs.length, 1)
as well as
#empty(action('Get_items').outputs)
What am I doing wrong here?
Background: The action('Get_items') is query retrieving items from a SPO site list using a Filter Query.
The action succeeds but the App Run Trace doesn't show any details on the outputs, in this case the expected empty array.
I managed to achieve the desired condition evaluation by correctly accessing the array the same way a for-each action does:
#empty(body('Get_items')['value'])
The documentation doesn't give a hint on this.
Accepted solution was not working for me for CDS entities, so I have solved it by using such condition:
#length(body('Get_items')['value'])
If I understand correctly it is converting array to string and empty array is converted to [], so you just have to check if the output of query is more than 2, then it means Get_Items is not empty.

Jmeter how to loop through a list of different properties in a single thread group or controller?

How to do a basic loop through different properties for a fixed set of controllers? Loop controller runs a set group a certain number of times, does not use properties though.
I can do modules, and set the values to properties for multi thread group usage, but how to pass the next iteration of the property, and run the loop again?
property x
do module (points to controllers)
next property
Say I have a list of 44 characters, and I want to loop through those characters in a ${name} while I'm doing a test. I'd very much not like to build 44 sets of controllers for one character change.
Please Note I cannot add extra files to my computer. It has to work via the stock available controllers. I'm using Jmeter 2.4 r961953
Thanks
I will elaborate slightly more about the BeanShell method. My assumption is that you'd like to do it within one User Thread, if so my proposal would be:
Create a Loop Controller.
Logic Controller->Loop Controller
Inside Loop Controller add following entries:
Config Element -> Counter
Preprocessors -> BeanShell preprocessor
Sampler -> yourSampler
The Counter element will be used as an index that will be used to choose valid value from our array, hence we need to specify a Reference Name for the Counter - let's say that it will be loopCounter.
Now we have to switch to BeanShell preprocessor and define the array of values. A great thing is that we have vars variable available and it gives us CRUD access to variables used in the scenario:
String[] varArray = {"Value1", "Value2"};
idx = Integer.parseInt(vars.get("loopCounter"))-1;
vars.put("myVariable", varArray[idx]);
And for the final step, inside mySampler we can use a variable in a regular JMeter way : ${myVariable}
JMeter API can be very helpfull if you want a more sophisticated solution.
There are a handful of different ways to loop through different values without adding external files:
Use beanshell controller, and write javascript to set your variable
Use a counter to increment by one
Use User Parameters
You can set it up so each loop gets a different value.
Check out the various configuration controllers to find one that works best for you.
EDIT:
I meant user parameters, not user define variables.
User Parameter
You'd need one row per variable with 44 columns. Sorry for the confusion.
User Parameter Structure
test plan
- Thread Group looped 44 times
-- User parameter
-- Request
Beanshell Method
Alternately, you could do an array in javascript in connection with a counter. The Beanshell samplers have access to Jmeter variables and properties, allowing the beanshell sampler to read the counter value. This may be a faster, cleaner way then using User Parameters.
Beanshell structure
test plan
- Thread Group looped 44 times
-- Counter
-- Request
---- Beanshell pre-processor
Beanshell Pseudo code would be
def counter = value of Jmeter Counter
def array = array of values
declare the variable "sampler_value" to be used by sampler
def sampler_value = array # counter
Counter with CharAt function
If you only need to generate characters, you could use the javascript function to utilize the function charAt, using the value from the Counter. Basic structure would be:
test plan
- Thread Group looped 44 times
-- Counter
-- Request
with the request using something like ${__javaScript(charAt(${counter})) as the parameter value. You may have to use JEXL instead of javaScript or evalVar/V/eval inside the charAt function.

Foreach Loop Microsoft SSIS - equivalent to break statement

Within a Foreach loop in SSIS is there a way that if a task fails you can break out of the loop to the next iteration?
I am looping over xml files and performing a lookup using values within this file, if the lookup doesn't return any values i'd like to report on this and then not perform any other tasks for this file. If there is no equivalent to a break statement how else can this be achieved?
You could also use a 'for' loop with a boolean condition such as looping while a variable is equal to true. Then when you want to break out of that loop, simply change the value of that variable to false and then you will break out of the loop.
Answering your question...a foreach loop, loops over a collection and other enumerable constructs so long as they exist to loop over. So you could either find a workaround, or just use a 'for' loop instead of a 'foreach' loop. That way you have more of a programming type control over the loop because you set the condition expression.
And yet another way would be to put a sequence container into your loop then put the conditional steps in the sequence container. Any decision that should 'continue' need only exit the sequence container.
Very simple to implement with all the control you could want including error trapping.
The lookup can redirect if there are no values returned, away from the successful flow.
You need the rest of your foreach loop to know there has been an error, so one way would be to set a package variable on error, just before you do the logging.
Then, in the 'success' arrow after your lookup you can change it to a conditional success, so that it only proceeds if the value of the variable is not the error value.
So I just had that problem and solved it by a) directing the failed task to a dummy task which did nothing and ended and b) setting the 'FORCEEXECUTIONRESULTS' to 'SUCCESS', which plowed through just the way I wanted it to.

Resources