cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FlatFish
Helper I
Helper I

200+ conditional if statement

Hi everyone,

 

I have a giant nested if statement that would require a ton of ifs. Does anyone know a better alternative to doing it rather than this. Regardless having such a big if statement isn't allowed anyway. 

Here is an example of one of the ifs that would continue for different users/banks etc.

If(emailToDropdown.Selected.Title = "fName lName" && bankSelectionDropDown.Selected.Title = "Bank" && userSelectDropDown.Selected.Title = "DS" && bankAccountTypeDropDown.Selected.Title = "Transactional" && accountOptionDropDown.Selected.Title = "Open an Account",
                                    Launch("mailto:fName.lName@email.com" & "?subject= New account opening Bank" & "&body=Hi fName," & "%0A" & "%0A" & "In connection with the new account opening at Bank, attached please find account opening documents submitted for signature." & "%0A" & "Bank accepts docusign" & "%0A" & "%0A" & "Please let me know if you have any questions regarding this request." & "%0A" & "%0A" & "Kind regards"),

 

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

Hi @FlatFish 

An alternative would be to store your email message templates in a table. This could be in an online data source like a SharePoint list, or it could be a static Excel file that you import into your Power App.

 

This table would include user and bank columns, and you would use those details to uniquely identify the message text.

 

From the button where you currently launch your email, you would call LookUp on this table to lookup the message text template, rather than construct the message text using an If.

 

The message text that you store in this table could contain placeholders such as "{fName}" and from your formula, you could call the Substitute function to insert the actual data values.

View solution in original post

3 REPLIES 3
timl
Super User
Super User

Hi @FlatFish 

An alternative would be to store your email message templates in a table. This could be in an online data source like a SharePoint list, or it could be a static Excel file that you import into your Power App.

 

This table would include user and bank columns, and you would use those details to uniquely identify the message text.

 

From the button where you currently launch your email, you would call LookUp on this table to lookup the message text template, rather than construct the message text using an If.

 

The message text that you store in this table could contain placeholders such as "{fName}" and from your formula, you could call the Substitute function to insert the actual data values.

Thank you for the reply Tim. That makes sense and will be most likely what I do. 

timl
Super User
Super User

You're welcome @FlatFish - the other benefit of storing the template text in an online table is that you could modify the message text without needing to republish your app.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,239)