Hi team, I have created a global variable called “Transcations” from which i need to pass the values, but i am keep getting an error, please look at the below code
for (var 1=0; i< response.length; i++)
{
if(response[i].freitext.includes("{{Transcations}}"))
{
pm.collectionVariables.set(“processInstance”,response[i].processInstanceId);
break;
}
It looks like you have a syntax error in the code:
for (var i = 0; i < response.length; i++)
{
if (response[i].freitext.includes("{{Transcations}}")) {
pm.collectionVariables.set("processInstance", response[i].processInstanceId);
break;
}
}
I’m not sure what you’re trying to do here though - What does the response body look like and does it include the string {{Transcations}}
?
No I have “Transactions” values in excel, need to pass that value here, i have created “transcations” as global variable here
I’m not sure what you mean by that 
What is the response body? Let’s start with the most basic this first.
Is Transactions
a heading that you have in a CSV file that you’re using as a datafile in the Collection Runner?
Or
Is Transactions
a global variable and you’re trying to read the variable value in the for
loop condition?
i have a CSV file as input which has “Transactions” column data, so my code should get the value from CSV file and should verify whether that value exists in my response. if so then should proceed the “processInstance” line
"
Is Transactions
a global variable and you’re trying to read the variable value in the for
loop condition?
answer is yes
var response = pm.response.json();
for (var i=0; i < response.length; i++)
{
var policyTrans = "{{Transcations}}"
if(response[i].freitext.includes(policyTrans))
{
pm.collectionVariables.set("processInstances", response[i].processInstanceId);
pm.test("Successfully transferred the processInstanceId", function () {
pm.response.to.have.status(200);
});
break;
}
this is my over all code, need to get “Transcations” data from CSV file
Ok, not sure why you have that same variable at the global level and in the data file?
You could use this to read the value from the data file.
let response = pm.response.json();
for (var i = 0; i < response.length; i++)
{
if (response[i].freitext.includes(`${pm.iterationData.get("Transcations")}`)) {
pm.collectionVariables.set("processInstance", response[i].processInstanceId);
break;
}
}
If you add this to a request, make sure you save that before running in the Collection runner.
I still don’t know what your response body is so I have no idea if response[i].freitext.
is even referencing the right place. 
@danny-dainton its working now, thank u so much
1 Like