Kinetic Button to Send Email

Scenario (btw Epicor Saas hosted environment):

  • Have existing classic customization code that when a button is clicked it gathers some information formats an email body and sends an email

  • Need to move this to Kinetic and have created a function to gather the information and format the body of the email

  • Also have created a Data Directive that calls my function and then passes return values to the Send Email widget and email is sent successfully

Questions:

  1. Is this the proper/best approach considering moving from custom code in classic to my options in Kinetic and the desire to send an email ?

  2. In my Data Directive I can use the “callContextClient.CurrentUserId” to determine the user, but how do I get the user’s email address from the userId ?

  3. Can the email body be in html format ?

Thank you for any assistance

Why do you need a data directive? Is it being automated or do you still want it called from a button?

Yes

You can build a query or use Linq to get the Email Address from Erp.UserFile.EmailAddress

I figured using the email widget was the easiest way to send an email without using additional code in my function

Yes, I’d prefer to kick it off using a button click event, but I saw another posting here regarding using a UD field that you modify that calls a BPM and sends an email

But I really don’t want the user to have to modify a field to kick it off

I’m still building it out…looking for ideas…fairly new at this

You can do a “Widget Function with Code” and get the best of both worlds.

I also shared an email function that handles attachments here:
https://www.epiusers.help/t/lets-share-useful-functions-sharing-is-caring/100371/1

Well since you are redoing it, and have the opportunity to do whatever you want,
what is your ideal way?

Or explain in more detail and I’m sure someone will have a suggestion on good ways
to handle it.

Let’s ping Mr. LowCode @JasonMcD

& @hmwillett if she’s not too overwhelmed lol

Originally I just wanted a button that calls a function and sends the email,
but the customization code I was starting with from classic looked overly complicated as far as sending the email went and I didn’t find an example here for doing it in a function.

But your post looks great, examples like that are what I am always looking for, I’m going to head down that path now

Thank you much

1 Like

Ugh, looking at your post with email function example…
Doh, I forgot to mention, cloud hosted (Epicor Saas)
Functions run on server, right ?

Can your example work with that ?

Yes of course.

You don’t necessarily have to use that though.

Me too :slight_smile:

I like to kick off BPMs/Functions like this with a change field event. I ise the button click event to change that field

A datetime UD field works great for this

  • Button Click changes UD date to DateTime.Now
  • Button click then calls update method and saves change
  • BPM fires on change datetime from any to another. Sends email.
  • Now you have a UD field that lets you trigger the BPM, but you also have a built in data point that lets you know the last time the email was sent

That’s pretty brilliant.

This should still primarily be a back-end task, so your approach is fine. Don’t get caught up in the “everything must happen in App Studio now!” because that is wildly wrong. Most things should be moving to the server with App Studio being the new front-end.

Kevin is correct. Use that to link to UserFile and get their email from there.

Not sure with the widget, but if you use code and System.Net.Mail, you can set IsBodyHtml to true.

1 Like