Need to make a decision tree for email routes.

Fahad Ahmed asked on January 7, 2019 01:48

Hi ,

I have a requirement to route the email based on condition, for instance, if there are 4 drop downs or check box fields on the form, depending on which values are selected , it will lead to an email address based on the selection the user made , when the form is submitted successfully.

I am thinking to make a module as it will be global, and using module I will be able to render a UI like a tree :

DROP DOWN FIELD 1 | |___OPTION 1---YES--- EMAIL ADDRESS | | NO _______ OPTION 2 -----YES--- EMAIL ADDRESS | | NO

Need to know if there is a simpler way , I was thinking to make custom page types, but it does not seems possible. Is it hte correct way to deal with this sort of requirements? Guindace and help required.

Correct Answer

David te Kloese answered on January 7, 2019 10:22

Depending on size and if the specs needs managing I'd store the options and corresponding email addresses in either Settings, a Custom table or perhaps build a complete Custom Module.

So you data isn't visible in the site as a value or display name.

Custom table could contain something like:

  • id - 1
  • desc - Tech Question
  • email - techsupport@mycompany.com

and

  • id - 2
  • desc - Order question
  • email - orders@mycompany.com

etc.

You'd use the ID and description in your user form... and retrieve the email in your code logic.

If you have more specs or questions we give you other options.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on January 7, 2019 12:37

If you mean online forms (bizform), then you can create a drop down field in the for, lets name it "EmailSelection" and define its values as list of options, for example:

sales@comapny.com;Sales   
support@company.com;Support  
legal@company.com;Legal  

Then, in the online form email notification setup, use the field macro in the TO field: {%EmailSelection%}

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on January 7, 2019 13:23

@Juraj - Since this was tagged as MVC and Kentico 11 would that still work? docs.kentico.com/k11/.../working-with-forms-on-mvc-sites

And for Portal Engine it would mean you have the value "sales@company.com" in the source of the rendered html (not sure you'd want that). Also if the email (and thus the value) needs changing it might get unexpected results...

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 7, 2019 13:30 (last edited on December 10, 2019 02:31)

@David - if it is MVC, then it is your custom MVC development and you can do whatever logic in the custom code you want. You can keep the logic and data on the code level or, as you said you can create custom module or custom table - depends on the exact implementation and project details.

If it is portal engine - I do not know all the details and specs. The above is just a proof of concept. If you do not want to have the email in the HTML, use numbers and then use IF condition in the macro (e.g. {%if (EmailSelection == 1){return "sales@company.com"}|(identity)GlobalAdministrator%})- I just did not want to complicate this.

0 votesVote for this answer Mark as a Correct answer

Fahad Ahmed answered on January 8, 2019 03:18 (last edited on January 8, 2019 03:19)

Good Day David and Juraj,

Thank you for the replies. I did a lot of thinking and now am going for the approach described by David.

1- Writing a custom module, due do freedom of desinging an interface, and the routing rules are global . 2- using a custom data table to store the configured rule(s). 3- using custom logic on submission of forms at client side to determine which email address(s) the notification routes to based on the options selected in the form.

Many thanks guys for your input .

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.