SalesOrder Form Update After BPM

Hello gang,

I’ve created a BPM using the SalesOrder.MasterUpdate method that checks the Ship-To country and changes the Group code of each line item based on if it’s domestic or international. For example, if the ship-to country is domestic then the Group could be “Crating”, and if it’s international then it could be “Crating - INTL”.

The problem I’m having is that after each line item’s Group is updated the form is not refreshed, so if a user changes something else and saves they will get the following error…

If I manually refresh each time it works fine. I’ve done some research and found that this is because the form needs to be refreshed, and there is no BPM command that can refresh the form. I did find recommendations for a way to do it as a customization to the Sales Order Entry form itself…
http://erp.ittoolbox.com/groups/technical-functional/epicor-l/bpm-refresh-screen-4665203

In the post it recommended using a Form Event Wizard with an event type of AfterAdapterMethod. I wasn’t sure which adapter to use, so I used the ordAdapter and changed the code…

But nothing changed. Still got the error each time I tried to save after the BPM had run. Any ideas of an effective way to refresh a form after a BPM process runs? Thanks for your time and any help you can offer!

Shawn

1 Like

Are you setting both the ID and Description of Product Group in the BPM?

1 Like

No, the BPM actually changes the ID but the Description shows on the form.

Actually you can pretty easily refresh the data on the form from the BPM.
After your code runs simply do a getbyid on the sales order and then use
this.dsHolder.Attach(dataset)
To attach the resulting data in your form thus refreshing / replacing it with the updated one

5 Likes

Going to ask a stupid one here, but does that work for E9 as well?

1 Like

Yes it does however in the ABL equivalent

José C Gomez
Senior Software Engineer

1 Like

I would try setting both of them in the BPM. I know I have had some issues in the past when I did not set both. Sometimes you need to and sometimes you don’t.

1 Like

Here is how you refresh the dataset in post processing on E10

Erp.Contracts.SalesOrderSvcContract orderSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db);
SalesOrderTableset OrderDs = orderSvc.GetByID(<YourOrderNum>);
this.dsHolder.Attach(OrderDs);

Here is how to do it in E9

DEFINE VARIABLE hSalesOrder AS HANDLE NO-UNDO.
RUN bo/SalesOrder/SalesOrder.p PERSISTENT SET hSalesOrder.
RUN GetByID IN hSalesOrder(INPUT <YourOrderNum>, {&output_dataset_SalesOrderDataSet}).
DELETE OBJECT hSalesOrder.
10 Likes

That works perfectly! Thank you Jose +1000! This is way more easier than messing with customization.

That ones bugged me since we implemented… Jose, you are going to be having a cheap Insights… Just running through my tab now…

The only addition would be to add a ‘using’ around ServiceRenderer.

using (Erp.Contracts.SalesOrderSvcContract orderSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
{
SalesOrderTableset OrderDs = orderSvc.GetByID();
this.dsHolder.Attach(OrderDs);
}

This immediately disposes the other service and closes up db connections, frees up memory. For a quick service not a big deal but if you do this a few thousand times during an MRP run your server will love you for it…

5 Likes

One glitch I’ve found with the code you suggested: If I happen to check the “One Time Ship” box, enter the info and save, the “One Time Ship” box becomes unchecked when the code “refreshes” the form. I can check the box, save, and watch it uncheck. Any ideas why this would happen?

Still using SalesOrder.MasterUpdate and using the “refresh” code on post-processing. Thanks for your time and help!

Shawn

Is the code running in post processing? What does the rest of the bpm do

1 Like

As described at the beginning of this post, I needed to change the Group based on the country (international or domestic). It was later decided that we also needed that feature for the One Time Ship (OTS). So I added a check in my original BPM to process only if the OTS had not been checked. Then I created a new Pre-Processing BPM to look for the OTS to be checked. It first checked to be sure a country had been entered and raised an exception if it hadn’t, then it runs the code to make sure the Group is set accordingly to the country, and then calls the Post-Processing directive to “refresh” the form. That’s where I would see the OTS box uncheck itself.

Since then, however, I have broke that newer BPM into half. I kept the country selection check with raised exception, added a check to see if country had been changed from one to another, and also kept the enable post directive call - all in the SalesOrder.MasterUpdate method. Then I created a new Data Directive for the OrderHed table, under In-Transaction, that ran the code to make sure the Group was set based on the country.

This was a nasty work around but I get the results I was looking for, and the OTS box stays checked.

This is the SalesOrder.MasterUpdate method directive…

And this is the OrderHed table data directive…

Is there a similar process that can be used for the Customer Maintenance table/form? I tried just changing all SalesOrder to Customer, but it didn’t do anything.

I have the same need for Customer Maintenance. I created a BPM to default some fields and need to refresh the screen. I tried updating it to “Customer” as you, but no luck either.

I tried the E10 code in post-processing BPM on SalesOrder.MasterDate. The code run when users check “Ready to Process” to update some information in OrderHed and OrderDtl.

If I add this code to refresh, it gives me an runtime error. If I don’t try to refresh, the updated information does not show on the form.

Any idea why I got the runtime error when trying to use this code to refresh

Thanks!