Question

UI Custom Button To Trigger BPM

  • 11 March 2022
  • 6 replies
  • 900 views

Userlevel 4

10.2.700

I’d like to find a way to trigger a BPM (either method directive or data directive) when a custom button is clicked in a UI customization.  Ideally I’d like this to happen whether or not a record is loaded into the form; in fact I’d like one general enough that it would even run in a dashboard customization if possible.

 

The incoming data will arrive in table UD10 and it will represent bar code scans that must be processed into customer shipment table entries.  I don’t mind creating a customization of Customer Shipment Entry, or the UD10 interface, or creating a dashboard and creating the button in there.  We have all the code samples we need for the creation of the packer records, we just need to know how to trigger a BPM from a UI customization button, even if no record is loaded into the UI form being used.

Thanks!

……...Monty.


6 replies

Monty,

This is what Functions are for.   That way there is no need to tap into a BO just to call a pre-process method.

 

 

Userlevel 4

@ken.nash 

Dear Ken,

 

Thanks much for this!  Do you have an example of calling a function call from a button click event handler?

 

I’ve remembered that before functions, some people designed auto-run code  in a data directive on the report table to be triggered by a report run, which could be done in my case as well, I think.  I just need some action the user can take, that will run my custom code.

All best,

..Monty.

Sure thing.  Here is something we called from a button click.

WIP is the function library

ExpRePrintSN is the function

// CALL NEXT SN Function
const string apiKey = "uCiKGvweGRfAEPQV4XxdEfPtSVOvMLqJkiJ57qXTf9VaJ";

var restClient = new RestClientBuilder()
.SetDefaultApiKey(apiKey)
.UseSession(oTrans.CoreSession)
.Build();

var functionContent = new RestContent(
new{
JobNum = system.JobNumber,
SerialNo = strSN,
PartNum = system.PartNum,
UserLocation = scan.ScanTo_UserLocation,
ScannedBy = scan.ScanTo_ScannedBy
});

var functionResponse = restClient.Function.Post("WIP", "ExpRePrintSN", functionContent, published: false);

I also have a few examples of working with the response of the function.  If you need help with that ask away.

Userlevel 3

Hi @mwilson ,

you can update any CallContext variable in your UI Customisation then capture it on the relevant BPM method as a trigger condition

Userlevel 4

Thanks one and all!  I will try these.

 

All best,

...Monty. 

Userlevel 3

you welcome @mwilson, i have done example for you mate, and this is the code that you need to add within click button event on the UI, ( i selected CheckBox10, you can choose any one but just make sure that it is not in use in any other BPM/UI custmisation for this BO

EpiDataView edvCallContextBpmData = ((EpiDataView)(this.oTrans.EpiDataViews["CallContextBpmData"]));
System.Data.DataRow edvCallContextBpmDataRow = edvCallContextBpmData.CurrentDataRow;
if ((edvCallContextBpmDataRow != null))
{
edvCallContextBpmDataRow.BeginEdit();
edvCallContextBpmDataRow["Checkbox10"] = true;
edvCallContextBpmDataRow.EndEdit();
}
EpiDataView edvUD01 = ((EpiDataView)(this.oTrans.EpiDataViews["UD01"]));
System.Data.DataRow edvUD01Row = edvUD01.CurrentDataRow;
if(edvUD01Row != null)
{
edvUD01Row["RowMod"] = 'U';
oTrans.Update();
}

HTH

Reply