How to get POHeader Object from Erp.POApvMsg Data Directive

Hi,
I want to send an email alert to notify the approver when a Purchase Order (PO) is created. I use the BPM Data Directive on POApvMsg.

Here is my code :

var ttPOApvMsg_xRow = ttPOApvMsg.FirstOrDefault();
var PONum = Convert.ToInt32(ttPOApvMsg_xRow["PONum"]);
var POApvMsg_Row = Db.POApvMsg.FirstOrDefault(x => x.PONum == PONum);
var PurAgent = Db.PurAgent.FirstOrDefault(y => y.BuyerID == POApvMsg_Row.MsgTo);
BpmContext.BpmData["Character02"] = PurAgent.EMailAddress;

The lines below are to get more information about the PO from the POHeader to put into the email body, but it doesn’t work. All of them are empty. I don’t know where I am wrong. Please help me.

var POHeader_Row = Db.POHeader.FirstOrDefault(x => x.PONum == PONum);
BpmContext.BpmData["Character07"] = POHeader_Row.TotalCharges;
BpmContext.BpmData["Character08"] = POHeader_Row.OrderDate;

Thanks,
Thanh.

Looks like your PO is not written to the DB at this stage.

You may need to move to a standard dd, and / or use a different trigger point.

@klincecum: PO was already created at this stage.
Flow: After PO ( PO Header, PO Detail) was created → Select Approve Check Box, the POApvMsg was created → Trigger sending email action.

It’s either not actually, or your variable is not right.