I am struggling to create a BPM on PO Update. When a user selects a particular GL account they need to fill in a UD field. The issue is that I am not always “seeing” the GL data on update, even though I can see it on the screen.
This is the code I am running. I am not always getting into the ttPORelTGLC for loop. Any trick that I should use to get this to work? Or is this more of a form customization.
string strPO = “”;
string strPOLine = “”;
string strPORel = “”;
bool blnStop = false;
string strRelNeedFix = “The following PORelease needs an EWO:\r\n”;
/*Here we will get the current PORel record */
foreach (var MyPORel in (from ThisPORel in ttPORel select ThisPORel))
{
strPO = MyPORel.PONum.ToString();
strPOLine = MyPORel.POLine.ToString();
strPORel = MyPORel.PORelNum.ToString();
Epicor.Customization.Bpm.InfoMessage.Publish("FirstLoop");
foreach(var RelTranGLC in (from ThisTranGLC in ttPORelTGLC where
ThisTranGLC.Company == Session.CompanyID &&
ThisTranGLC.Key1 == strPO &&
ThisTranGLC.Key2 == strPOLine &&
ThisTranGLC.Key3 == strPORel &&
((ThisTranGLC.GLAccount == "587000|01")
|| (ThisTranGLC.GLAccount == "588100|01")
|| (ThisTranGLC.GLAccount == "588200|01")
|| (ThisTranGLC.GLAccount == "588500|01")
|| (ThisTranGLC.GLAccount == "641300|01|3000")
|| (ThisTranGLC.GLAccount == "641400|01|3000")
|| (ThisTranGLC.GLAccount == "643050|01|3000")
|| (ThisTranGLC.GLAccount == "651000|01|3000")
|| (ThisTranGLC.GLAccount == "651100|01|3000"))
select ThisTranGLC))
{
Epicor.Customization.Bpm.InfoMessage.Publish( RelTranGLC.GLAccount);
if (MyPORel.UDField<System.String>("EWO_c") == "")
{
strRelNeedFix = strRelNeedFix + "Rel: " + MyPORel.PORelNum + "\r\n";
blnStop = true;
Epicor.Customization.Bpm.InfoMessage.Publish(strRelNeedFix);
}
if (blnStop)
{
var message = strRelNeedFix +"EWO field cannot be blank when GL Account is one of the following:\r\n• 01-587000\r\n• 01-588100\r\n• 01-588200\r\n• 01-588500\r\n• 01-641300-3000\r\n• 01-641400-3000\r\n• 01-643050-3000\r\n• 01-651000-3000\r\n• 01-651100-3000";
throw new Ice.Common.BusinessObjectException(
new Ice.Common.BusinessObjectMessage(message)
{
Type = Ice.Common.BusinessObjectMessageType.Error,
});
}
}
}