Add Custom Row to ERP Table via BPM

,

Hi All,

I’m currently working on a BPM to automatically add checklist items to a project upon its initial creation, and am running into a problem with adding rows to the ProjectTask table. I’m trying to add the rows to the ttProjectTask table in a Post-Processing Method Directive. The error that is occurring is:

My code currently is:

Let me know if this is not the best way to accomplish this task, it’s my second week using the system!

Thanks in advance for your help.

2 Likes

You should NEVER add your own rows manually to any table in Epicor without using the business objects. I recommend a thorough reading of the Ice Customization Guide and the Ice Tools Guide. To create a new task on a project you need to use the Project business object and do a trace to make the right BO calls to accomplish this.
For example this uses the CustShip business object to create a new “row” in Customer Shipment Misc Charge. You would need to do the equivalent of this with the Project business object

using(var custShipSvc = Ice.Assemblies.ServiceRenderer.GetService(Db))
    {
        CustShipTableset csts = new CustShipTableset();
        csts = custShipSvc.GetByID(packNum);
        custShipSvc.GetNewShipMisc(ref csts, packNum, 0, 0);
        custShipSvc.GetShipMiscDefaults(ref csts, miscCode);
        var x = csts.ShipMisc.Where(r => r.Added()).FirstOrDefault();
        x.DocMiscAmt = 999999.99M;
        x.DspMiscAmt = 999999.99M;
        x.MiscAmt = 999999.99M;
        custShipSvc.Update(ref csts);
    }
2 Likes

@josecgomez, thanks for the heads up and quick reply. I’ll be sure to read over those guides before I get back to working on this.

Is there anything else you would recommend reading over as a new Epicor user?

No problem,
That’s a big no no with epicor you want to always use the business objects to write data. There is a lot of logic that gets bypassed if you just create your own records, leading to data corruption and worse! Plus support @aidacra will probably spank you if he finds out.
Recommended Leisurely Reading Guide:
Sign In
Sign In
Sign In
Sign In
Sign In

Plus the Education courses in Customization are very good.
Feel free to ask questions here there are many of us watching and answering as much as we can. We do not mind helping each other :slight_smile: we have a wonderful little community going!
Also lots of videos in youtube

1 Like

What if the table is small enough and there is not a direct dedicated BO:Method for updating the table other than the main BO update. An example is a Sales Order Update method is used to update the table OrderHedUPS.

Additionally, it may not be possible to call a BO from a BPM. For example just declaring assemblies and BO for the Sales Order during a Quote Update method will result in compilation errors during the save of the BPM.

Below are just a few of the errors that you would get:
There is at least one compilation error.
Update.CommonTypes.cs(308,33): error CS0433: The type ‘QuoteQtyTable’ exists in both ‘Erp.Contracts.BO.Quote, Version=10.2.500.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.SalesOrder, Version=10.2.500.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’
Update.CommonTypes.cs(333,33): error CS0433: The type ‘HedTaxSumTable’ exists in both ‘Erp.Contracts.BO.Quote, Version=10.2.500.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.SalesOrder, Version=10.2.500.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’
Update.CommonTypes.cs(338,33): error CS0433: The type ‘PartSubsTable’ exists in both ‘Erp.Contracts.BO.Quote, Version=10.2.500.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.SalesOrder, Version=10.2.500.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’
Update.CommonTypes.cs(343,33): error CS0433: The type ‘TaxConnectStatusTable’ exists in both ‘Erp.Contracts.BO.Quote, Version=10.2.500.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.SalesOrder, Version=10.2.500.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’
CustomizationAdapter.cs(333,30): error CS0433: The type ‘ETCAddrValidationTableset’ exists in both ‘Erp.Contracts.BO.Quote, Version=10.2.500.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’ and ‘Erp.Contracts.BO.SalesOrder, Version=10.2.500.0, Culture=neutral, PublicKeyToken=5d3fa3c7105d7992’
CustomizationAdapter.cs(9,132): error CS0738: ‘QuoteSvcCustomization’ does not implement interface member ‘QuoteSvcContract.ETCValidateAddress(int, int, out bool, out bool, out string)’. ‘QuoteSvcCustomization.ETCValidateAddress(int, int, out bool, out bool, out string)’ cannot implement ‘QuoteSvcContract.ETCValidateAddress(int, int, out bool, out bool, out string)’ because it does not have the matching return type of ‘ETCAddrValidationTableset’.