BPM Save Action after setting a field?

We’re using EDI, and have a BPM that sets a field when on Demand Entry GetByID. The BPM sets the field but it’s not saving to the database. Is there a way to trigger a save function in a BPM?

There is a way to use GetByID and do a save (update) but it definitely is not as easy as using an update method. Is there a reason you have to use GetByID?

I found even a manual save won’t write the comments to the database, so I figured the BPM was in the wrong spot.

What our issue is, we have EDI customers that want static Order Comments and they do not transmit it via their EDI file. Our first thought was a BPM when processing Demand into a Sales Order, but I couldn’t find any thing in Trace logging. I tried a few shot-in-the-dark BPMs but none worked.

So second idea was, since we have our CSRs review Demand before processing into an order, is to add the BPM to Demand Entry (and Demand Mass Review) when our CSRs open the Demand to review it before processing into an order.

We are storing the customer specific comments in the DemandContractHead.OrderComments (Table.Field for clarity, not the actual table name). The BPM I tried does pull the data and put it into the temp-table but when processed it doesn’t carry over.

You can do it on GetByID but its probably super slow to do it via GetByID / Update. You could just a LINQ query in the BPM to update the data… Mind you I don’t know which tables you are using but as an example with OrderHed something like this…

var oh = (from order in Db.OrderHed.Where(r=>r.OrderNum==123435).FirstOrDefault();
if(oh!=null)
{
oh.OrderComment = "This is my new awesome comment";
Db.Validate();
}
1 Like

Did you review the method ChangeCreateNewOrder in BO DemandEntry?

I’ll try another spot instead like Dan suggests.

The code I used in the Set Field syntax and it works to put the comment into the temp-table just need to find the right spot to get it to save back to the database before the PO is processed into a Sales Order.

ttDemandHeadRow.OrderComment = string.IsNullOrEmpty(ttDemandHeadRow.OrderComment) ? Db.DemandContractHdr.FirstOrDefault(p => p.Company == callContextClient.CurrentCompany && p.DemandContractNum == ttDemandHeadRow.DemandContractNum).ContractComments ?? "" : ttDemandHeadRow.OrderComment 

/*  
IF ttDemandHeadRow.OrderComment is null 
THEN set to DemandContralHdr.ContractComments 
ELSE ttDemandHeadRow.OrderComment
*/

@danbedwards, you were close and got me thinking.

I ended up getting it to work via a In-Transaction Data Directive on DemandHead table with the
Set field syntax as I posted above. I’m having our users do more testing in our Pilot/Test environment before we go live with it but so far it’s working.

2 Likes