BPMs for Automated Email On Employee Expenses Submitted And Approved

Can anyone help me set up custom code in BPMs to fire emails :

  1. to the approval person when an employee submits expenses (
  2. To the employee when their expenses have been approved?

I have set up the equivalent for POs requiring approval.
I found this post great for the PO approval code:

For employee expenses I have made a pre-processing directive on the conditions that an employee expense status has been changed from any to ‘S’ and Approval Required is true.

Then I’ve set up a post-processing directive enabled by the pre-processing directive, but don’t know what code to enter.

Any helps or pointing me in the right direction would be great!

Thanks

1 Like

Here is the basic framework for What I use to send emails to someone when a new vendor is added. We have a security group named EM_NEWVENDOR and individuals in that group will receive an email when a new vendor is added to Epicor . This is triggered in a Standard Data directive with the condition block “There is at least 1 added row in the ttVendor Table”. Here is the code for the Custom Code Block

//Email Variables
string bpmEmail_to = string.Empty;
string bpmEmail_cc = string.Empty;
string bpmEmail_subject = string.Empty;
string bpmEmail_body = string.Empty;

string newVendor = string.Empty;
string newVendorID = string.Empty;
//
//
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
// Get each new Record//
foreach (var rd in ttVendor.Where(rd => rd.Company == callContextClient.CurrentCompany ))
{
newVendor = rd.Name;
newVendorID = rd.VendorID;
}

//Set up Mail Message
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            mail.From = new System.Net.Mail.MailAddress("VendorAlertDD@SnoWay.com");


//TO DO:  Get UserGroup member(s) email addresses to notify when this occurs

foreach(var em in Db.UserFile.Where(em => em.CurComp == callContextClient.CurrentCompany  && em.GroupList.Contains("EM_NEWVENDOR")) )
{
    mail.To.Add (em.EMailAddress.ToString());
    bpmEmail_to =  bpmEmail_to +"\n" + em.EMailAddress;  ///used for testing 
}

bpmEmail_subject = " A new Vendor has been added";

bpmEmail_body = "Please review the following Vendor and enter additional Information as appropriate. " + "\n" + "\n";
bpmEmail_body = bpmEmail_body + "\n" + "\n" + "Vendor ID: " + newVendorID + " , VendorName: " + newVendor;


//Set up Mail Client
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
        
            client.Port = 25;<<<<<<<<<<<<<<<<<--- I had to get this from the IT Dept
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Host = ",Enter YOUR Email Host" ;
            mail.IsBodyHtml = true;
            mail.Subject = bpmEmail_subject;
            mail.Body = bpmEmail_body;
            client.Send(mail); //Remove comment when GO LIVE !! // <<<I use the following line uncommented to test
//Epicor.Customization.Bpm.InfoMessage.Publish(bpmEmail_to);//Remove line when GO LIVE !! ??

Db.Validate();
txScope.Complete();

}

I hope this helps

Mmmm didn’t load as I expected. All of the code, both outside the scroll-able window and inside the window is needed

Dean

Thanks Dean :slight_smile: