i use a lot of pm.collectionVariables.set() to temporary store variable from another request an re-use it again
we can see a list of Environment and Global Variable
but I don't know where to find a list of the stored collectionVariables.
It is in collection's information.
Related
I have a scenario where I have some JSON ("lldp" in the image below), and I need to find a particular key and pull all of its values from within. The particular key I need to pull is dynamic and is identified as the 'thisPort' variable. All of this is shown in the screenshot below.
The lldp data basically looks like this. Note how the ports are not within a list. Any given instance of the lldp data may contain anywhere between 1 - 48 ports.
lldp = {
"port1": {"stuff":"things"},
"port2": {"stuff":"things"},
"port40": {"stuff":"things"}
}
I assumed I could do something like "lldp.thisPort" to access the keys and variables withing, however this produces useless errors and doesn't work. In this case I passed it three different 'thisPort' variables from a list, so presumably its the same problem three times, and not three different problems.
'thisPort' does correctly come across to the Evaluate function as a string that should lead to a valid JSON path. Eg, 'lldp.thisPort' does seem to translate to a valid path like 'lldp.port1', but Evaluate doesn't seem to agree and I get an error.
Using variables (or any other 'dynamic' way of working), how can you access the keys/values within some JSON as part of a postman flow, when the path to the thing you're trying to pull is dynamic?
You can use $lookup(lldp, thisPort) inside the Evaluate block to get the values inside the thisPort object.
Postman allows to generate random dummy data by using pre-defined variables, on example this one would be replaced by random company name:
{{$randomCompanyName}}
Using pre-defined variables multiple times return different values per request.
The question is how to save once generated value to the variable for further usage on example in tests, something like(it doesn't work):
pm.variables.set("company", {{$randomCompanyName}});
Thanks.
You can use the .replaceIn() function with that {{...}} syntax in the sandbox.
pm.globals.set("company", pm.variables.replaceIn('{{$randomCompanyName}}'));
I've used a global variable to store the value as you would want to use it again. You could also use either the environment or collectionVariables scope to do the same thing.
Ok, so I have some smarty variables assigned on the checkout page in my shop. Problem is that when I want to use them -for example
{$address_collection.firstname}
I get an undefined index notice. I am certainly doing something wrong, but what?
on your screenshot $address_collection is array of objects, so to access to array element you need to use key, like $address_collection[124] and this element will contains address object,
where to get first name:
{$address_collection[124]->firstname}
If in smarty you want to access the array then you have to mention key of the array then you can use the values.If in your tpl file you want to print the array which you assigned then you have to write like
{var_dump($address_collection)}
Where $address_collection is the variable which from which you assigned values.
Now for access the values in your tpl file you have to mention key like:
{$address_collection['key_name']}
I hope it would help you.
Workflow generates three files (header, detail, trailer) which I combine via post-session command. There are two variables which are set in my mapping, which I want to use in the post-session command like so:
cat header1.out detail1.out trailer1.out > OUTPUT_$(date +%Y%m%d)_$$VAR1_$$VAR2.dat
But this doesn't work and the values are empty, so I get OUTPUT_20151117__.dat.
I've tried creating workflow variables and assigning them via pre-session variable assignment, but this doesn't work either.
What am I missing? Or was this never going to work?
Can you see the values assigned to those variables on the session log or do they appear empty as well?
Creating workflow variables is what I'd try, but you need to assign the values with the post-session variable assignment.
Basically, you store values in a variable in your mapping and pass the values up to the workflow after the session succeeded. Here is how you can achieve that:
Define a Workflow variables $$VAR1 and $$VAR2
Define the variables in your mapping, but chose different names! So i.e. $$M_VAR1 and $$M_VAR2
In your mapping, assign the values to your mapping variables through the functions SetVariable(var as char, value as data type)
In your session, select Post-session on success variable assignment.
In step 4, the current value from $$M_VAR1 (mapping variable) is stored in your workflow variable $$VAR1 and can then be used in the workflow in command tasks like you asked.
A few notes:
I'm not 100% sure if the variable assignment is exectured before the post-session command. If the command is executed first, you could execute your command tasks in an external command task after your session.
Pre-Session variable assignment is used if you pass a value from a workflow variable down to a mapping variable. You can use this if your variables $$VAR1 or $$VAR2 are used inside another mapping and need to be initialized at the beginning.
When we configure a field as a choice list and set up some initial values, where are they stored? I understand we could configure them as a dynamic list by using a separate table. I am trying to understand what happens with the static list.
Thanks.
Choice list data gets stored in the lsml file, which is why it's only a reasonable option for very static data.
To add/delete values, the developer has to make the change & redeploy the entire applictaion.
Does that help with what you were wanting to knmow?