Epicor Function in BPM Code

Have any one tried consuming function from BPM using C# Code not with the help of Invoke.

If you have done please share me the Sample

Could probably just use any http client in your code to do so by calling the Fx via the rest api

Ok Sure will try and let you know.

Is this what you ended up doing @Dhanalakshmi

Curious if there is a class that can be used to call a function within BPM

Answered my own question, reason I wasn’t seeing this was because I was in an in-trans data directive…

Not sure why In-trans directives are excluded, but I was able to make it work in in-trans using C# code. Created a simple function that accepts String input, and outputs a String also. I found the code by building a DD Standard, then exploring what the generated C# code looked like. Once you save an enabled BPM, it builds the code to the following folder:

C:\inetpub\wwwroot\ERP102700UpgradeTest\Server\BPM\Sources\DT\

Once I had the generated code, I was able to use it within a C# code block in-trans.

string strOUT;

System.String arg1 = ("mark D");
var result = (Tuple<System.String>)this.InvokeFunction("BV","markFunc",Tuple.Create(arg1));
strOUT = result.Item1;

this.PublishInfoMessage(strOUT, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "","");

My thoughts as to why Epicor are not showing the widget in in-trans could be because of the confusion over which row the call should be made against, the unchanged or changed? Somebody else more knowledgeable will hopefully jump in!

5 Likes

Mark, I have a function with these input params:

Would my function call be this then?

int PO = 73071;
int POLine = 1;
decimal newdocunitprice = Convert.ToDecimal(0.69);
this.InvokeFunction("UpdatePO","UpdateApprovedPO",Tuple.Create(PO),Tuple.Create(POLine),Tuple.Create(newdocunitprice));

I get an error like this when I do that:

Description: BPM runtime caught an unexpected exception of ‘InvalidCastException’ type.
See more info in the Inner Exception section of Exception Details.
Program: efx.updatepo.dll
Method: AdapterRun
Original Exception Type: InvalidCastException
Framework Method: A001_CustomCodeAction
Framework Line Number: 0
Framework Column Number: 0
Framework Source: A001_CustomCodeAction at offset 889 in file:line:column :0:0

It’s been a long while since I looked at this.

Your current error could be this line:

decimal newdocunitprice = Convert.ToDecimal(0.69);

InvalidCast is probably because you’re trying to convert a decimal, to a decimal.

Thanks Mark, it was actually the Tuple.Create… I didn’t need that and my function wasn’t expecting a Tuple.

Based on these examples, I am not sure by what you mean ‘My function wasn’t expecting a Tuple’ ?
Did your function require 3 input parameters?

this.InvokeFunction(“UpdatePO”,“UpdateApprovedPO”,Tuple.Create(PO),Tuple.Create(POLine),Tuple.Create(newdocunitprice));

I needed to just pass my variables: PO (integer type), POLine (integer type), Newdocunitprice (decimal type).

Instead I was passing a tuple.

Hey Taylor
Try something like this this.InvokeFunction(“UpdatePO”,“UpdateApprovedPO”,Tuple.Create(PO, POLine, newdocunitprice)); and let me know if it works.