Unable to add multiple parameters in IF condition

Hi,

From a feeder file i am taking values called product id, product type and weight.
I am using these products to add items to basket, Based on product type add to basket request gets changes.
I added if condition as below to check whether product have weight and type of the product, but it is giving compilation issues, can someone please help me in resolving this issue?

if(v_c_maxWeightValue > 0) && (p_ProductType == “CatchWeight”) {
var requestBodyAddToBasket="{“items”:[{“id”:""+v_c_ProductId+"",“newValue”:"+v_newValue+",“oldValue”:"+v_oldValue+",“newUnitChoice”:“pcs”,“oldUnitChoice”:“pcs”,“catchWeight”:"+v_c_maxWeightValue+"}],“loggedInAction”:“update-trolley-item”}"

}else if (v_c_maxWeightValue > 0) && (p_ProductType == “LooseQuantity”) {
var requestBodyAddToBasket="{“items”:[{“id”:""+v_c_ProductId+"",“newValue”:"+v_newValue+",“oldValue”:"+v_oldValue+",“newUnitChoice”:“kg”,“oldUnitChoice”:“kg”}],“loggedInAction”:“update-trolley-item”}"

}
else{
var requestBodyAddToBasket="{“items”:[{“id”:""+v_c_ProductId+"",“newValue”:"+v_newValue+",“oldValue”:"+v_oldValue+",“newUnitChoice”:“pcs”,“oldUnitChoice”:“pcs”}],“loggedInAction”:“update-trolley-item”}"

}

Compilation error -

11:30:42.634 [ERROR] i.g.c.ZincCompiler$ - /home/ec2-user/gatling/user-files/simulations/addToBasket.scala:94:31: not found: value &&
if(v_c_maxWeightValue > 0) && (p_ProductType == “CatchWeight”) {
^
11:30:42.637 [ERROR] i.g.c.ZincCompiler$ - /home/ec2-user/gatling/user-files/simulations/addToBasket.scala:94:35: not found: value p_ProductType
if(v_c_maxWeightValue > 0) && (p_ProductType == “CatchWeight”) {
^
11:30:42.639 [ERROR] i.g.c.ZincCompiler$ - /home/ec2-user/gatling/user-files/simulations/addToBasket.scala:99:39: not found: value &&
}else if (v_c_maxWeightValue > 0) && (p_ProductType == “LooseQuantity”) {
^
11:30:42.642 [ERROR] i.g.c.ZincCompiler$ - /home/ec2-user/gatling/user-files/simulations/addToBasket.scala:99:43: not found: value p_ProductType
}else if (v_c_maxWeightValue > 0) && (p_ProductType == “LooseQuantity”) {

Thanks in advance

Addtobasket.scala (7.1 KB)

You’re missing parentheses around your conditions.
This should compile:
if( (v_c_maxWeightValue > 0) && (p_ProductType == “CatchWeight”) )

P.S. - The issue has got nothing to do with Gatling. Checking out StackOverflow etc for these kinds of scala compilation issues would help you getting a quicker resolution.

Thanks,
Shiva

Thanks Shiva…Its working fine post implementing parentheses.

Thanks,
Swetha. G