Epicor Discussion Forums Homepage
Forum Home Forum Home > Epicor University > Epicor ERP Tools and Technical
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

Trigger a BPM from a button control.

 Post Reply Post Reply
Author
Message
Brian C. View Drop Down
Newbie
Newbie


Joined: 14 October 2015
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brian C. Quote  Post ReplyReply Direct Link To This Post Topic: Trigger a BPM from a button control.
    Posted: 14 October 2015 at 08:32
Is it possible to trigger a BPM using a button control?

If so, some suggestions would be helpful.

Thanks!
Back to Top
mbtaylor View Drop Down
Employee
Employee


Joined: 24 July 2007
Location: China
Status: Offline
Points: 105
Post Options Post Options   Thanks (0) Thanks(0)   Quote mbtaylor Quote  Post ReplyReply Direct Link To This Post Posted: 21 October 2015 at 05:06
You can trigger a BPM (object) by using the button to call either (1) call the Business Object and make some change the then initiates the BPM or (2) runs ABL .p code on server (using the 'run' command in your client customisation) that calls the BO.

There is an Advanced Embedded Customisation course Ive just been reading the content to verify my answer) that covers using adapters and business objects in this way. Contact Epicor University or your consultant.

Back to Top
Brian C. View Drop Down
Newbie
Newbie


Joined: 14 October 2015
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brian C. Quote  Post ReplyReply Direct Link To This Post Posted: 21 October 2015 at 06:41
Thank you for the reply, I'll look into that.
Back to Top
mbtaylor View Drop Down
Employee
Employee


Joined: 24 July 2007
Location: China
Status: Offline
Points: 105
Post Options Post Options   Thanks (2) Thanks(2)   Quote mbtaylor Quote  Post ReplyReply Direct Link To This Post Posted: 21 October 2015 at 21:30
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);
          }
     }
Back to Top
hopper View Drop Down
Newbie
Newbie


Joined: 12 March 2016
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote hopper Quote  Post ReplyReply Direct Link To This Post Posted: 14 March 2016 at 02:12
Originally posted by mbtaylor mbtaylor wrote:

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 bathmate review 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);
          }
     }


Thanks mbtaylor for this helpful post. And I agree the ability to reach into contexts and object datasets to add our own actions and stuff is super powerful and I'm just getting into all the possibilities now.

Brilliant.


Edited by hopper - 21 May 2016 at 13:20
Back to Top
REG81462 View Drop Down
Newbie
Newbie


Joined: 02 February 2017
Location: Chattanooga TN
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote REG81462 Quote  Post ReplyReply Direct Link To This Post Posted: 02 February 2017 at 06:44
Can you show me how to modify this code to work on a QuoteHed record?  I have the button created and the Business Object Assembly Reference added for Quote Adapter.
Rick Griffith
ERP Specialist
Lectrus
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 10.17
Copyright ©2001-2013 Web Wiz Ltd.