Hello,
So we had a working PO Approval Email when we were still on 10.0 where it would send an email to the approval person when a buyer clicks on the approve checkbox over their PO limit. It would trigger when the ApprovalStatus is “P”. We upgraded to 10.1 earlier this year and I just found out yesterday that those notifications are no longer working. So when I did a trace, there is no more ApprovalStatus = “P”. Everything is now “U”. Has anyone else had this issue? How did you resolve it? I am sharing my code below and hopefully, someone will be able to help me. Thank you.
Method: ChangeApproveSwitch
Post Process
Erp.Tables.PurAgent _PurAgent;
Erp.Tables.UserFile _UserFile;
foreach(var ttPOHeader_it in (from ttPOHeader_Row in ttPOHeader where !String.IsNullOrEmpty(ttPOHeader_Row.RowMod) && (ttPOHeader_Row.Approve == true &&
string.Compare(ttPOHeader_Row.ApprovalStatus, “P”, true) == 0) select ttPOHeader_Row))
{
string vAprID = string.Empty;
string vAprName = string.Empty;
decimal vPurLimit = decimal.Zero;
string vBuyerEmail = string.Empty;
_PurAgent = (from PurAgent_Row in Db.PurAgent
where PurAgent_Row.Company == Session.CompanyID &&
string.Compare(PurAgent_Row.BuyerID, ttPOHeader_it.BuyerID, true)==0
select PurAgent_Row).FirstOrDefault();
if (_PurAgent != null)
{
vPurLimit = _PurAgent.POLimit;
vAprID = _PurAgent.ApprovalPerson;
vBuyerEmail = _PurAgent.EMailAddress;
_UserFile = ( from PurAgent_Row in Db.PurAgent
join UserFile_Row in Db.UserFile on
PurAgent_Row.Name equals UserFile_Row.Name
where PurAgent_Row.Company == Session.CompanyID &&
string.Compare(PurAgent_Row.BuyerID, vAprID, true)==0
select UserFile_Row).FirstOrDefault();
if(_UserFile !=null)
{
string vFrom = string.Empty;
string vTo = string.Empty;
string vCC = string.Empty;
string vSubject = string.Empty;
string vBody = string.Empty;
string vApprover = string.Empty;
vApprover = _UserFile.EMailAddress;
vFrom = vFrom + "NoReply.E10@*******.com";
vTo = vTo + vApprover;
vCC = vCC + vBuyerEmail;
vSubject = vSubject + "Approval Pending for PO#" + System.Convert.ToString(ttPOHeader_it.PONum) + " (Company " + System.Convert.ToString(Session.CompanyID) + ": Plant " + System.Convert.ToString(Session.PlantID) + ")";
vBody = vBody + "Purchase order # " + System.Convert.ToString(ttPOHeader_it.PONum) + " requires approval.\rBuyer listed for this PO is " + System.Convert.ToString(ttPOHeader_it.BuyerIDName) + ".\rSupplier: " + System.Convert.ToString(ttPOHeader_it.VendorName) + "\rPurchase Order Amount: $" + System.Convert.ToString(ttPOHeader_it.TotalOrder) + "\rBuyers Purchase Limit: $" + System.Convert.ToString(vPurLimit);
var mailer = GetMailer(async: true);
var message = new Ice.Mail.SmtpMail();
message.SetFrom( vFrom);
message.SetTo(vTo);
message.SetCC(vCC);
message.SetSubject( vSubject);
message.SetBody(vBody);
mailer.Send(message);
}
}
}