Syntax Erro
Question

Hi 

I'm making a website, I'm using a Product Catalog template, I've already changed everything and everything is working as it should, the only problem is that I'm getting a syntax error and I can't understand what I should do to solve this problem .


capture_20220424142249803.bmp



Hi,

here you cannot use two variables without any operator

If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Rings
 and CategoriesFilter.Rings Entities.Color.Primary,

here the CategoriesFilter.Rings and Entities.Color.Primary  are two different variables, check that logic.

If condition should always return a boolean value, if you are using and  in the If condition then you should use  like

If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Rings and COLOR = Entities.Color.Primary,

I will provide you with the simplest way to do this nested If without syntax error and make changes according to your logic. 


If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Rings ,
If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Necklaces ,
If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Bracelets ,
Entities.Color.Neutral3, ""),""),"")


Here these double quotes are the falseSelector of the If condition.


I hope this will help.

Hi @Ana Andrade,

In your case, you have missed a comma at the end of the first line.


Please check the syntax for If in expression.

Syntax:

If(Condition, trueSection, falseSection)


If you are trying to implement nested If then it should be like,

If(Condition1, trueSelection1, If(Condition2, trueSelection2, falseSelection2))


Best Regards,

Sreejith


Hi

I put a comma but it still gives an error.

capture_20220424150308698.bmp

Please check with the syntax I shared, Here you are using 3 If conditions so each one should need a trueSelection and a falseSelection. 

In this case, your second If is used in the True selection of the first, and the False case is not defined. You can use double quotes at the false selection when u don't want to have anything.

Can you please share the expression as text, it will be more helpful to explain.

Do you Want me to put the expression here?


If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Rings and CategoriesFilter.Rings Entities.Color.Primary,
If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Necklaces and CategoriesFilter.Necklaces Entities.Color.Primary,
If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Bracelets and CategoriesFilter.Bracelets Entities.Color.Primary,
Entities.Color.Neutral3)))


Hi,

here you cannot use two variables without any operator

If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Rings
 and CategoriesFilter.Rings Entities.Color.Primary,

here the CategoriesFilter.Rings and Entities.Color.Primary  are two different variables, check that logic.

If condition should always return a boolean value, if you are using and  in the If condition then you should use  like

If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Rings and COLOR = Entities.Color.Primary,

I will provide you with the simplest way to do this nested If without syntax error and make changes according to your logic. 


If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Rings ,
If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Necklaces ,
If(GetProductCategories.List.Current.ProductCategory.Id = Entities.ProductCategory.Bracelets ,
Entities.Color.Neutral3, ""),""),"")


Here these double quotes are the falseSelector of the If condition.


I hope this will help.

It helped a lot and it's already working thank you very much :)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.