Combining Kinetic Events

I have a custom kinetic dashboard deployed, and one of the buttons on my form is working great. The event driving the button contains a dozen conditions to check for values in the textboxes to make sure the user didn’t skip anything. I would like to take this event and make it available to use in another event. I am not sure how to ask this correctly. I want to be able to nest events.

In my example, I have a long event that checks everything over before adding a new record to my UD table. I want to do the same check for my update button. How can I execute the same list of field checks without copy/pasta, or manually recreating the event?

The ideal solution I can imagine has the ability to create an event and save it as an event that can be called from another event.
test inception GIF

1 Like

Isn’t that, basically, what functions are for?

1 Like

Good question! I just used functions in classic Epicor successfully. I am not sure how I would create events from the function. Can you say a little more about the path you think might work?

1 Like

Well, I’m not 100% on what you’re doing here, aside from wanting to reuse some code. Your example sounds like it could be accomplished with BPM’s on a GetNewUDRecord and Update method (ideal since that’s where business logic should live). You can also trigger the function from a form event (doable, though not necessarily desirable).

As to what the function would look like, I’d either pass in the relevant dataview, or just pass in some key fields. It’s highly dependent on what I’m looking to do. One of the more common patterns I use, is to have the function test the required values, then return either a boolean or simple string with the text of whatever error or notice message I want the user to see.

I then have a if widget on the BPM test the output, and throw an error since messaging is more reliable and flexible when done on the BPM and not the function.

Stub BPM where the bulk of the work is on the function.
image

3 Likes

Make it a no trigger event.
Then create separate events triggered by whatever event, and use the event-next widget to call the event that has all the logic in it.

3 Likes

I can explain a bit more. The form I have is for temporarily storing inventory information before it is stocked properly back in Epicor. The first button I got working was AddRows. OnClick, the button fires off this event:


You can see the 8 fields where I perform the validation check. Basically, is this field blank? If it is then show a warning can cancel the event. If it is not blank, then continue the event. At the end it triggers my UBAQs custom action which adds the row to the UD table.

For my next button I want to implement UpdateRow. For this I will perform the same field validation to make sure the user didn’t delete a value from a field or leave it blank. I would like to copy the event conditions and dialogs into the new event so I don’t have to manually insert them. I can copy one widget at a time, but not a bunch of them all together.

Ohh this sounds interesting. I guess I have to rebuild the original part of the event I want to copy in its own no-trigger event. I will give it a shot.

2 Likes

I think you should be able to copy the existing event and then just delete what is not needed.

3 Likes

Again, I’d try to get something that complicated running entirely server side, but you can pack it into a function called by the onClick event.

4 Likes

Then you have to allow the data to save so that the server side code can see it. By putting it in the UI you can intercept prior to saving which is often a nicer experience for the user. I think each approach has its place.

I have a similar situation where I am using a function to do the validation because it needs to go look at data in different places. But when all the info you need is right there, its a lot simpler to just do it in the event.

4 Likes

Not at all. Just pass the unsaved data into the function. Again, you can pass the entire dataset you’re working on, or individual values, or anywhere in-between.

3 Likes

Yeah that’s true. I was thinking if you wanted to do it with a bpm.

1 Like

You can even do it via BPM, as changing many fields fire off server calls. That is my preferred method of managing business logic, when available.

That’s literally what my screenshot above is from: a BPM attached to a ChangeJobNum method that sends the user an angry message when they attempt to create a job using a job# that’s outside of our tight requirements. Because people love using job#'s as arcane secret codes.

3 Likes

code GIF

3 Likes

Understand Captain America GIF

2 Likes



So I created a new “Event” called CheckFields. In there it just does the conditions and dialog boxes. Then in the button click event I use the event next to do the field check before committing the record. Did I set this up correctly? The data is getting into TransView OK, and getting into CallContextBPMData OK. No error code is getting returned from the try/catch. I am just getting the server side error again.

1 Like

I ran into this when using event-next to avoid repeating code… I’m not sure what the best way to interrupt event execution is (maybe event-cancel is cancelling only the current event, not the whole string of events that follow it)

So I redesigned to perform my long set of conditions and set a variable to flag for cancellation that I checked after the even-next widget

It feels dumb to add another condition, but having your big condition set all together is important for if changes have to be made, you just change your conditions in one place (instead of hunting for all the events that have those same condition checks).

3 Likes