BPM - Access info from previous method (for email alert on review journal approval)

I’m trying to create a BPM that emails the Journal Entry creator when their entry is approved in the Review Journal. Unfortunately, when approving, Epicor changes the journal entry UserID from the creator to the approver. This then email’s the review journal approver, not the original creator.

What’s odd, is the trace doesn’t show this happening - both the submitted parameters and returned values show the original creator’s user ID as the original RvJrnTr.UserUID.

Is it possible to have a BPM on the previous method to record the journal entry person into a stored variable, that the later BPM can access?

image

BO Erp.Proxy.BO.ReviewJrnImpl Method Steps:

  1. GetList (gets all review journal entries in the search window)
  2. GetJournalHeader (pulls in the JE that you selected in the search window)
  3. GetJournalTreeLeaf (no idea, seems to repeat GetJournalHeader)
  4. Ice.Proxy.Lib.BOReaderImpl > GetRows (gets Chart of Accounts segments)
  5. ProcessJournal (where I have my BPM, this is the method that gets triggered when you approve or cancel the RJ)
  6. GetJournalHeader (clears out the RJ page)

Not the solution I was aiming for, but I moved it from a method directive to a data directive. When a review journal is approved, Epicor deletes it from the RvJrnTr table, so I used the Rowmod=D condition to trigger the email.

image

image

I know you’ve solved it already, but that’s one of the purposes of the CallContextBPMData fields.

Interesting :laughing:

Um, thanks :slight_smile:

Wow! That was way easier than I thought. Thanks Kevin for the subtle push. Now I can delete those 2 data directives. I didn’t know if setting the CallContextBPMData would be hard, but not at all. I grabbed the user (and a few other fields) from the previous method ‘GetJournalHeader’ before Epicor overwrote it, and set that to the ShortChar01 (Date01 and Num01 & Num02) field. Then called that in my final BPM on the ProcessJournal method.

I hope this helps someone else use CallContextBPMData. It’s not scary at all, lol!

image

image

image

image

1 Like

No, but it occasionally has gotchas, and I don’t know all of them.

1 Like

Yup. I got greedy and fell down the rabbit hole… I added the Debit and Credit amounts from the RvJrnTr table, which is in the GetJournalHeader dataset.

Works great when there’s only one journal per Journal Entry group. As soon as you add a second, Epicor errors. I’m thinking it’s because there are two RvJrnTr.DebitAmount values now, and Epicor doesn’t know how to assign it to one CallContextBPMData field.

image

I tried changing it to a string (hoping Epicor would iterate through the rows and put a comma in between each record, but it still errors.

image

	Business Layer Exception
	
	The table ds.RvJrnTr has more than one record
	The table ds.RvJrnTr has more than one record
	
	Exception caught in: Epicor.ServiceModel
	
	Error Detail 
	============
	Correlation ID:  e26316b4-5baf-40e4-b0eb-5885efe5946b
	Message No.: 1
	Description:  The table ds.RvJrnTr has more than one record
	Program:  Epicor.Customization.dll
	Method:  GetSingleRow
	Line Number:  68
	Column Number:  17
	Table:  ds.RvJrnTr
	Message No.: 2
	Description:  The table ds.RvJrnTr has more than one record
	Program:  Epicor.Customization.dll
	Method:  GetSingleRow
	Line Number:  68
	Column Number:  17
	Table:  ds.RvJrnTr

Yes at that point, you need to do it yourself.

You can still use the CallContextBPMData to pass it,
and if you’re craftier than me with widgets, @JasonMcD @Mark_Wonsil you
can probably do it with widgets too.

I drop some Json in a a character field quite often and pull it out on the other end.

Nothing wrong with that!

You basically have to do the same thing, but it might take another (sub)query to string_agg multiple records into one string before assigning it to a BPMContext field.

That’s why you were pinged :slight_smile:

Thanks @klincecum and @Mark_Wonsil!

Now off to figure out how to aggregate the records into one string in either a BPM widget or C# (code copying…). So far everything in the search seems to be related to BAQ’s. ChatGPT is lying to me and says I can do calculated fields in BPM widgets.

@klincecum - I found Tim’s thread on using JSONhttps://www.epiusers.help/t/callcontextbpmdata-hack/54893.

Then found this: Standard Directive - Table has multiple rows - #25 by Ricky90

You should be able to do calculated fields in widgets… you have to pre-define the fields, but then inside C# code you can set the value of any of your pre-defined UD BPM Fields.

1 Like

Not a big fan of skinning cats, so here is one scratching his butt. Adage still applies.

cat scratches GIF