BPM to Update RMAComment field on "CreateRMA" BO Method

Hey everyone,

I’m pretty knew to Epicor and am having to learn most of this on my own. That said, please forgive me if the below question is stupid.

At my company, we would like to have the Case description get copied over to the RMA Comment when an RMA is created off an existing case via the CreateRMA Business Object method. To accomplish this, I created a very simple Post-Processing BPM on the HelpDesk.CreateRMA business object method.

The BPM contains a single “Execute Custom Code” action which runs the below snippet:

********** CUSTOM CODE **********
string comment = String.Empty;
using (var txScope = IceContext.CreateDefaultTransactionScope())
foreach (var caseCmnt in (from row in Db.HDCase.With(LockHint.UpdLock) where row.Company == Session.CompanyID && row.HDCaseNum == helpDeskCaseNum select row))
comment = caseCmnt.Description;
foreach(var rma in (from row in Db.RMAHead.With(LockHint.UpdLock) where row.Company == Session.CompanyID && row.HDCaseNum == helpDeskCaseNum && row.RMANum == newRMANum select row))
rma.RMAComment = comment;
********** End Code **********

“newRMANum” and “helpDeskCaseNum” are both BPM variables and are set to the values I’m expecting when this code snippet runs.

I’m not receiving any exceptions, but when this code block executes, the RMAComment does not get updated. I suspect this is because Epicor can’t “see” the added records even though the code is executing Post-Processing. Clearly I’m missing something and I imagine it’s pretty straight forward. How can I access the newly added RMA in order to update the comment field? Any pointers would be very much appreciated :slight_smile:

Try this code as an In-Transaction Data Directive on RMA Head:

foreach (var tt in ttRMAHead.Where(tt => tt.Added() && tt.HDCaseNum != 0))
	tt.RMAComment = (from row in Db.HDCase where row.Company == tt.Company && row.HDCaseNum == tt.HDCaseNum select row.Description).DefaultIfEmpty("").First();
	// Alt Version
	//tt.RMAComment = Db.RMAHead.Where(R => R.Company == tt.Company && R.HDCaseNum == tt.HDCaseNum).Select(R => R.Description).DefaultIfEmpty("").First();

Thank you Jason! That did the trick.