Differentiate between ShipTo Update and Customer Update

Good afternoon,

I am trying to figure out a way to make something work. The gist of it is when a specific document type is attached to a ShipTo record, the system will query XFileRef and XFileAttch and check if there is a record matching the CustNum and ShipToNum and if it exists, then it checks a box, letting users know the check has been completed. I have gotten everything working but the issue I am running into now, is the code is ran when the Customer record is updated, along with when the ShipTo record is update. I have found this is because Customer and ShipTo use the same service.

Any ideas how I could run this code just when ShipTo has been edited?

I have the event running Before AfterUpdate

I was going to put a condition before the erp-function call, but I am unsure of how to write those expressions, besides really basic equal/not equal statements. If there is a resource used to write those, that would be great too.

Thanks for any help!

1 Like

When it runs on Customer Update, is the Ship To blank? You could key off of that. :man_shrugging:

As described, this scenario sounds like a good fit for a server-side BPM (Business Process Management) rather than embedding this logic in the UI. This does a couple of things, it decouples the logic from the Client (Rest, Web, Fat) and it moves the logic server side where it is a lot easier to see what was and wasn’t updated.

I’d throw a method directive on the Update method called when you do an attachment (do a trace) and use that to check the appropriate checkboxes this will also tell you if it was a Customer or a ShipTo Record much easier.

Under idea circumstances logic would be 99.99% server side, UX is only for Visual Logic (hide / show fields, highlight, client side validation). Always strive to decupling your business logic from your view logic

3 Likes

That is actually how I got the error was because I tried updating a Customer record with no ShipTo, and it gave me an error “Parameter value cannot be null: ShipToNum”. I was going to just add that as a condition, “{ShipTo.ShipToNum}” == “” but it felt lazy and was curious if anyone had something more elegant?

1 Like

Thanks for the in-depth response. Truth be told, I’m piggy-backing off some work that was done for us prior to this and was trying to keep it consistent. I will try to do it the way you described and keep you updated. I do find the Method/Data directives to have better conditionals as well.

1 Like

If you do a Trace on the Client you’ll see a call to Customer.Update bo with the following payload. Yo should be able to easily piggy back off this to run your logic and do your checkbox checking.

Notice that an attachment on ShipTo will have a Record Added RowMod=“A” on ShipAttach table, vs a Customer attachment would have a Record Added RowMod=“A” on CustomerAttach table.

{
  "method": "POST",
  "url": "https://TLD.EPICOR.SERVER/epicorkineticgold/api/v1/Erp.BO.CustomerSvc/Update",
  "queryParams": {},
  "headers": {
    "Content-Type": "application/json",
    "callSettings": "{\"Company\":\"C001\",\"Plant\":\"040\"}",
    "x-epi-request-etag": "true",
    "x-epi-extension-serialization": "full-metadata",
    "Accept": "application/json, text/plain, */*"
  },
  "body": {
    "ds": {
      "CustomerFSPriceList": [],
      "MXCustomerFiscalText": [],
      "CustBank": [],
      "CustBillTo": [],
      "CustChild": [],
      "CustDfltDocType": [],
      "CustIC": [],
      "CustLabExpRate": [],
      "CustMandate": [],
      "CustMFBill": [],
      "CustomCrdPool": [],
      "Customer": [],
      "CustomerAttch": [],
      "CustomerDiscPriceLst": [],
      "CustomerDocs": [],
      "CustomerDocsSH": [],
      "CustomerPriceLst": [],
      "CustRestriction": [],
      "CustUPSEmail": [],
      "EntityGLC": [],
      "GlbCustCred": [],
      "MangCust": [],
      "NAMember": [],
      "Partner": [],
      "PECustWhldHist": [],
      "ShipTo": [],
      "ShipToAttch": [
        {
          "Company": "C001",
          "CustNum": 3643,
          "ShipToNum": "1",
          "DrawingSeq": 0,
          "XFileRefNum": 0,
          "SysRevID": 0,
          "SysRowID": "00000000-0000-0000-0000-000000000000",
          "ForeignSysRowID": "00000000-0000-0000-0000-000000000000",
          "DrawDesc": "BOM2.xlsx.Errors.txt",
          "FileName": "a5d8fbf3-8086-ef11-a827-000d3acf90ae;\\C001\\ApInv\\ShipTo\\BOM2.xlsx.Errors.txt",
          "PDMDocID": "",
          "DocTypeID": "ApInv",
          "RowMod": "A"
        }
      ],
      "ShipToDiscPriceLst": [],
      "ShipToLabExpRate": [],
      "ShipToMFBill": [],
      "ShipToPriceLst": [],
      "ShipToRestriction": [],
      "ShipToSrch": [],
      "ShipToUPSEml": [],
      "TaxExempt": []
    }
  }
}
5 Likes

I am going down the path you have suggested, but am I missing something? I set a condition to evaluate if the RowMod is “A” AND if the DocTypeID is correct, and if True, I want it to check the box. I use Set Field to set ShipTo.EXRAttached_c of the changed row to true but it doesn’t check it? I have also put a message to display after true and that works, but the check box doesn’t populate. Thank you

1 Like

There is no data in that ship to table you’ll have to look it up and update it in your BpM cause epicor only sends partial datasets

2 Likes

That makes sense now that you say it out loud. :upside_down_face:

3 Likes

So assuming that I only have ds.ShipToAttch dataset, I tried to create a variable in the BPM with the customer tableset and a boolean variable to set the checkbox when the attached document is the correct type and the RowMod is A. I then took that, and used the Fill Table by Query and Queried the ds.ShipToAttch, because that’s all I have to work with (right?) so I set the display fields to company, CustNum, and ShipToNum and inserted it into my ds.ShipToEXR.ShipTo table and the configured mapping mapped everything correct except my boolean variable that I set manually.

Then I tried to invoke Customer.Update to update the ShipTo using that dataset table I created. It failed and said that ShipToNum already exists, but I was trying to update it. Thoughts?

1 Like

Images for visual people
Current BPM

Query:

Binding

Invoking Customer.Update

1 Like

Error Message
image

1 Like

I would say do a get by id on customer

Then use a update by table query to update the ship to table and call update

1 Like