BPM to send email when task completes and quotehed UD field = true

I’m creating a BPM to send an email when QuoteHed.Quoted=TRUE and QuoteHed.PowerPoint_c=TRUE. This is working with Quote.Update, but not when completing the final task and marking it won sets Quoted=TRUE.

I did a trace, saw that Task.Update is being called, so I cloned what I did for Quote.Update, but the QuoteHed fields aren’t part of the Task data set.

How do I get those fields to evaluate?

I thought of a standard data directive on QuoteHed, but the email template in standard data directives doesn’t have access to the field variables (for CustID, Name, Amt, and QuoteNum).

What should be my next step?

Thanks for the help!

I was looking at this a while back and couldn’t make it work either so we went a different direction. I should’ve asked here like you did, so let’s see if there is an answer out there now…

I’ve been messing around with this today some more. I was hoping I could set arguments / variables with a data directive, and use that to drive the email, but it doesn’t have the Customer ID or Name fields available in the QuoteHed row.

Could I do something with tags? Or invoking functions or a different BO?

I suppose I could do a dashboard, but I really don’t want to make the sales people have to check one more thing every day when an on-demand email or alert would be best.

If you have access to custom code, you could just set BPM variables. I assume you can use them in the email widget. Something like:



var mytask = ttTask.Where(r=>!r.Unchanged() && r.RelatedToFile=="QuoteHed").FirstOrDefault();

if(mytask!=null)
{
  int myquotnbr = 0;
  int.TryParse(mytask.Key1,out myquotnbr);
  var myqh = Db.QuoteHed.With(LockHint.NoLock).Where(r=>r.Company==callContextClient.CurrentCompany && r.QuoteNum==myquotnbr).FirstOrDefault();
  if(myqh!=null) {
    var mycust = Db.Customer.With(LockHint.NoLock).Where(r=>r.Company==myqh.Company && r.CustNum==myqh.CustNum).FirstOrDefault();
    if(mycust!=null) {
     //set BPM variables used during email here or something similar? 
    }
  }
}

Tanner - Thanks! I’m giving that a try.

To make sure I’m getting it - That code block sets variables from the QuoteHed that I can use in my condition and email widget blocks? I would add variables for QuoteHed.Quoted, QuoteHed.QuoteAmt, and Customer.CustID

Like this?
image

Yes that is what I was thinking. If you store the information in BPM Variables, they should be available in your condition checking and email widget. You could also do this all in code… I assume the task is not longer marked as modified (!r.Unchanged()) in the POST directive though so you might have to tinker with it a bit. Good luck!

Hi Tanner - I got stuck modifying your code to add the variables from the QuoteHed and Customer tables, so I thought I’d try to get at the QuoteHed criteria via “Number of Rows in My Query”.

Seems Epicor doesn’t like joining the QuoteHed table to Task via Key1, which is a string in Task, but Int in QuoteHed. I get this error, but not sure how to to fix it:

image

image

There is at least one compilation error.
Update.Post.ReferralEmail.cs(120,143): error CS1061: ‘int’ does not contain a definition for ‘ToLowerInvariant’ and no accessible extension method ‘ToLowerInvariant’ accepting a first argument of type ‘int’ could be found (are you missing a using directive or an assembly reference?)

I just ran a test and I don’t see an issue in our environment (10.2.300.37) when creating just a BAQ with no tt table. FWIW I typically steer away from joining in memory tables to Epicor tables as it can cause performance issues (could be a bug as well). Try using the db tables for the join in the query. To get only the information for the related ttTask table, add it to the grid and then add filter criteria on the Erp.Task to select the correct record.

Hope this help,

Tanner

Table relations:

Criteria to filter table: