Trigger a BPM from a button control

I was simply trying to make sense of this post by Epicor: 

Basically what you need do is:
1. create button the form.
2. use the Tools menu on customisation screen to add custom assemblies reference to the object you have attached a BPM to.
3. set an event on the on-click of the button (use the customisation wizard for this).
4. in the script editor you need to add the code and have the button click event call that piece of code. Below is my example code from a UD08 maintenance form with a button that basically puts data into the BPM context (not the data table), sets the rowmod to force the BPM engine to run BPMs, and then in my BPMs i have method directives at pre and base processing which check the BPM context field, and if set to my value just do a display saying "hello". This general method you can then use for anytype of validations, or special actions on screen. 

Very powerful underused/overlooked feature of Epicor ICE is the ability to reach into contexts and object datasets and add your own unique actions, editing, and integrations. Have fun!



     private void epiButtonC1_Click(object sender, System.EventArgs args)
     {
          // ** Place Event Handling Code Here **
          CallAbcCodeAdapterUpdateMethod();
     }

     private void CallAbcCodeAdapterUpdateMethod()
     {
          //MessageBox.Show("CallAbcCodeAdapterUpdateMethod");
          try
          {
               // Declare and Initialize EpiDataView Variables
               // Declare and create an instance of the Adapter.
               AbcCodeAdapter adapterAbcCode = new AbcCodeAdapter(this.oTrans);
               adapterAbcCode.BOConnect();
               bool result = adapterAbcCode.GetByID("A");

               if (adapterAbcCode.CallContext == null)
                    adapterAbcCode.CallContext = new Epicor.Mfg.Core.CallContext.CallContextDataSet();
               if (adapterAbcCode.CallContext.BpmData.Count == 0)
                    adapterAbcCode.CallContext.BpmData.Rows.Add(adapterAbcCode.CallContext.BpmData.NewRow());

               adapterAbcCode.CallContext.BpmData[0].Character01 = "GO";

               // Call Adapter method
               adapterAbcCode.AbcCodeData.AbcCode[0]["RowMod"] = "U";
               bool resultUpd = adapterAbcCode.Update();

               // Cleanup Adapter Reference
               adapterAbcCode.Dispose();

          } catch (System.Exception ex)
          {
               ExceptionBox.Show(ex);
          }
     }

Testing on BPM calls from user defined forms.


What are the steps required to add a button click trigger a BPM from another form?  Example, a user defined form adding the ABC custom reference trigger a BPM to the ABC form from the UD form?


Thanks.

To trigger a BPM you have to call the Method for which it was written, for example for a BPM on ABCCode.GetByID you have to invoke that method from your customization. What is your end goal?


Jose C Gomez
Software Engineer


T: 904.469.1524 mobile

Quis custodiet ipsos custodes?

On Tue, Mar 15, 2016 at 7:20 PM, sanfranc415@... [vantage] <vantage@yahoogroups.com> wrote:

Â
<div>
  
  
  <p></p><p><span>Testing on BPM calls from user defined forms.</span></p><p><span><br></span></p><p><span>What are the steps required to add a button click trigger a BPM from another form?  Example, a user defined form adding the ABC custom reference trigger a BPM to the ABC form from the UD form?</span></p><p><span><br></span></p><p><span>Thanks.</span></p><p></p>

</div>
 


<div style="color:#fff;min-height:0;"></div>