50
Views
8
Comments
Getting issue in if expression editor
Question
Application Type
Reactive

Hi,


I created a block in which there are nearly 40 questions and lot of if else conditions should be added in the block to display the questions.  I added almost all the if else conditions but at one of else condition I was unable to put the condition and open expression editor. It shows a loading symbol instead of cursor. Can I know the solution for this?

2023-01-26 16-03-24
Ana Agostinho

Hello Gayathri Gali, 


Can you share more details and be more clear about the issue? Can you post fo example some prints of the behavior in order to understand it better? 

Best regards, 

Ana 

UserImage.jpg
Gayathri Gali

There are a lot of IF else conditions in my block and I try to click one if else expression editor to give the condition but cursor is changing to loading symbol and not allowing me to give the condition.

2023-01-26 16-03-24
Ana Agostinho

I understood that. 

Why not split the block into smaller blocks, subdivide the complexity, and simplify your logic? 

2020-07-29 19-08-40
Sanjay Kumar Sahu

Hello @Gayathri Gali,


Using multiple if-else condition is not a good practice, instead use switch case for primary case and later you can use nested If for your switch cases if required. In your case, there is chance of OS not able to read deep rooted condition or might be a syntax error. 

Also for your specific case, you can use your block inside a list and display 1 question with all options within it, this will surely reduce conditions.

Hope it helps!

UserImage.jpg
Gayathri Gali

Thanks for the reply,

I agree that it is because of many if else conditions. But how can I use a switch widget on block. Mostly, switch is used on client actions right?

UserImage.jpg
Narendra Maheshwari

Hi,

It could be because the web block is large. If you can split it into a few more web blocks, it will be easier to manage in the future. If you can not split it due to business or complexity, the best thing to do is close and reopen your module and wait until it loads completely.




2020-07-29 19-08-40
Sanjay Kumar Sahu

Yes Switch case can be used in client/server actions flows, not in UI widget, thought you are doing some data manipulation in client action of web block. 

Can you tell us if all these if-else condition causing issue is for a single question or all 40 questions? if possible post screenshot of widget tree, hiding sensitive data.

UserImage.jpg
Gayathri Gali

There are lot of if else conditions in the block and if I try to click on any question if condition, it is showing the error.

Can I know is there any alternative to create this block of questions without using many if else?

It's like a kind of nested if else 

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