Passing info from BPM to Function

I have created a series of Method Directives on CustShip.Update Master

PreProcessing: If ReadyToInvoice changes from false to True, Enable Post Directive

Post Processing: If this directive has been enabled from PreProcessing directive above, Invoke Function B2.

B2 is configured with the three requirements of PackID, CustNum, and OrderNum.

I know for a fact the info is passed along in the BPM as I have checked every step using a message and inserting the info to make sure it is populating. However, when I put up a message in the function, it comes back blank. Like their isn’t any info coming from the BPM.

The function has ShipHead and ShipDTl in the libraries, along with CustShip in the services.

What am I missing?

Hi Will,

When I’m calling functions from a BPM, I use this syntax (I do it via custom code)

this.InvokeFunction("LIBRARY","FUNCTION", Tuple.Create(param1, param2, param3));

Tuple is used to pass the parameters!

2 Likes

Thank you! I will give this a shot.

For the parameters, do I just place in there the filed? Example: Ordernum is ShipHead.OrderNum? Having a bit of trouble here.

Yes. For example, If you want to pass OrderNum, do that;

this.InvokeFunction("LIBRARY","FUNCTION", Tuple.Create(ShipHead.OrderNum));

Something like that:

var shipHeadRow = ds.ShipHead.LastOrDefault();

if(shipHeadRow != null)
{
  this.InvokeFunction("LIBRARY","FUNCTION", Tuple.Create(shipHeadRow.OrderNum));
}
1 Like

Last question on this…(I think! LOL!) how is the parameters picked up by the function?

You have to define them in Function Signature → request Parameters:

I’ve been setting them as Int, do I need to set them up as something else? Sorry for all the questions, this is the first time I have used functions, so still earning. This is the one area I am really fuzzy on, connecting the function to the parameter.

@stoyanlevakov why are you using a tuple?

1 Like

@stoyanlevakov you can create a function with multiple parameters in the signature and you don’t need to use a tuple to pass them…

2 Likes

Hmm, I’ve been using it like that and it works, so I never questioned it :d

So, I have a BPM that has the ordernum, packnum, and custnum I need to pass to the function. I have created the parameters in the signature but the function still isn’t picking them up. Trying to figure out where I went wrong and why it isn’t picking them up.

Basically looking to go from If ReadyToInvoice on Shiphead goes from false to true, then change three fileds in OrderHed. The BPMS does the first part, checks for the flag to go from false to true in preprocessing, and then activates the function in post processing. Except, the function doesn’t seem to get the info. So I have something wrong, just not sure what I am missing.
Thoughts?

What does your function signature look like?

Is it one input parameter that you pass multiple values to using a tuple?

Or what?

Really just need the Order Number to do what I need to do correctly.

Yeah so now you call the function in your bpm custom code:

this.InvokeFunction(“LIBRARY”,“FUNCTION”, OrderNumber, CustNumber);

Make sure both parameters you are passing (OrderNumber and CustNumber) are int.

2 Likes

@utaylor @stoyanlevakov

Quick question: I have the parameters going through the Functions now. THANK YOU! Now, however, when I run the parameters into the Function that has OrderHed, the OrderHed table isn’t populating any info in it.

It is set up where the BPM sends the parameters to BPMPickup Function that is using CustShip, and that sends the parameters to OrderFieldChange which is using SalesOrder.MAsterUpdate.

Here is how it is setup:

image

Will my friend, what do you mean the OrderHed table isn’t populating any info in it?

The green are from the parameters. The blue are me trying to get info form the Order table itself.

When I run the bpm, I get this:

Only the Parameters actually show up, the others I am trying to get form the OrderHed table are not coming through.

Why are you calling master update to get the dataset for an order?

Try GetByID and pass the ordernumber.