Running Multi Company Direct Server process Via Function

Brilliant. Splitting it up with separate triggers was the key.

  • Method Directive on Customer Update: Call the MCD function if the GlobalCust of all rows is True.
  • Data Directive on GlbCustomer Table: Call the linking function if the CustNum of the changed row is 0 and the GlbCompany of the changed row is equal to the [parent company].

If there is interest, I can post details of the functions once I’ve had some time to clean them up and do more testing.

To circle back to the original post, it is possible to trigger the Multi Company Direct Server Process using a function with only widgets, so no coding is required:

  1. Do a trace of your typical Multi Company Direct Server Process to get the parameters you pass in your environment.
  2. Create a new Library in Function Maintenance.
  3. In “References,” add ERP.Proc.MultiCompanyDirect to services and add SysAgent in tables (you might not need to include SysAgent but you need something to be able to fill a variable table).
  4. In “Security,” add all companies that will need to participate.
  5. Create a new function.
  6. In the function designer, first add an “Invoke BO Method” for erp.multicompanydirect.SubmitToAgent.
  • For the “ds” binding, select “Create new variable” and name it.
  • The remaining parameters can be determined from the bottom of your trace, but you can set the “mainProgram” to an expression to identify that it was called by a function.
  1. Add a “Fill Table by Query” setter and set the “specified table” to the ds variable you created in the BO method.
  2. In the Query, add the ICE.SysAgent table and in the Display Fields, add the AgentID (this could be anything; it isn’t actually used).
  3. In the mapping section, set the values to match the values from your trace. Ensure Continuous is false and TenantMode is true to have it process on all companies.
  4. Link Start > Fill Table > Invoke BO Method

I’m still in the testing process, but this has worked so far.
Thanks for all the help, automating the Global linking process has been on everyone’s wish list here since we started using it, and this might actually get us there.

Super news! Glad it worked!

yes - please drop the cleaned-up code when you get a chance and mark the solution so others can see it was solved when they search for answers

Excellent Thank you!!! I have got MCD running through the function, I’ve created a DD to Fire my Linking function after the process is complete but struggling with getting the appropriate part tried passing the being trying to use a query to focus on the most recent but have been struggling with the date.

My GlbCustomer table Data Directive looks like this:

  • Condition: The ttGlbCustomer.CustNum field of the changed row is equal to the “0” expression
  • Condition: The ttGlbCustomer.GlbCompany field of the changed row is equal to the “[Parent Company]” expression

When these conditions are true, I use two “Set Argument/Variable” actions:

First Setter:

  • Set the strCustID argument/variable to the ttGlbCustomer.FirstOrDefault().GlbCustID expression
    Second Setter:
  • Set the intCustNum argument/variable to the ttGlbCustomer.FirstOrDefault().GlbCustNum expression

Here, you manually enter the tt part in the expression, and strCustID and intCustNum are variables I created. I haven’t yet looked at the GlbParts table, but you’ll likely need to grab something like GlbPartNum and pass it to your linking function.

My linking function is actually two functions. The first loops through all the child companies, and within the loop, it calls the second function in the context of each of the child companies to perform the actual linking. I will post that later, but it sounds like you already have working code for the linking.

Hi ,

I am also working on MCD for customer. If you share the linking function code or steps to link that will be helpful.