Epicor Function Examples: Update a Table, Call It, Schedule It
epicor function examples
Also searched as
- epicor function update table
- epicor call function from code
- epicor schedule function
Short answer
An Epicor Function takes typed inputs, runs widgets or code, and returns outputs. You can update data through a business object call or the table widgets, call the function from a BPM, from Application Studio or over REST, and schedule it through an external scheduler or a task agent pattern that fits your release.
Applies to: Epicor Kinetic 2021 and later with Epicor Functions; REST path shown for the v2 API
How to build, call and schedule a function
- 1Create a library in Epicor Functions Maintenance and add a function with a clear name such as UpdateJobNote.
- 2Define input parameters (for example JobNum as string, Note as string) and output parameters (for example Result as string).
- 3In the designer, add a widget that reads or updates data: call a business object method for supported updates, or use the data widgets for queries.
- 4Add a Condition and error handling so a missing record returns a meaningful result instead of an exception.
- 5Save and enable the function and set security so only the right users or integration account may call it.
- 6Call it from a BPM with a Call Function widget, from Application Studio with a function call action, or from outside with REST.
- 7For recurring work, trigger it from a scheduler that calls the REST endpoint, or use the scheduling capability your release provides.
- 8Log the outcome and test with sample input before enabling the schedule.
Updating a table the supported way
The safest way to change Epicor data is through the business object that owns it, because that path applies the same validation and BPM rules as the client. In a function, that means a call to the relevant service method with the right dataset, not direct SQL against the database.
Writing directly to tables bypasses validation, audit and directives, and can leave records inconsistent. For a custom UD table or UD column, update through the standard UD business object or the data widgets provided for it. If a requirement seems to need raw SQL, reconsider the design first.
Calling a function
From a BPM, use the Call Function widget and map the widget inputs to fields or variables. From Application Studio, bind an event to a function-call action and map the form data. Both paths run on the server, so the function sees the same security context as the user.
From outside Epicor, a function is exposed on the REST API under the efx path with the company, library and function name. Authenticate with an API key and a user account, and keep the key out of source control.
POST https://yourserver/yourinstance/api/v2/efx/COMPANY/MyLib/UpdateJobNote
Content-Type: application/json
{ "jobNum": "J0001", "note": "Rush" }Scheduling a function
Scheduling depends on release and licensing, so confirm what your version offers. The robust, version-independent pattern is an external scheduler (Windows Task Scheduler, a job server or an integration platform) that calls the function's REST endpoint with an API key at the required interval.
Whatever you choose, make the function idempotent: running it twice should not duplicate work. Add logging and an alert on failure, because a silent scheduled job that stops is hard to notice.
Try it here, free
Epicor Function Library Design Template
A design document for an Epicor function: signature, inputs, outputs, logic notes, security, test cases and sign off.
Common pitfalls
- !Updating tables with raw SQL and bypassing validation and BPM.
- !Using a personal account's credentials for a scheduled call instead of a service account.
- !Creating a function that is not idempotent and then scheduling it.
- !Forgetting to set library security, leaving update functions callable by too many users.
- !Hardcoding company or site IDs rather than passing them in.
How an ERP-grounded AI assistant handles this
An assistant over your Epicor data can read the current state a function will touch and show it before anything changes, which makes review faster. ERPray is read-only by default, so any write-back remains a function or a business object call with human approval.
Frequently asked questions
Can an Epicor Function update a UD table?
Yes. Use the UD business object or the data widgets designed for it so validation and directives apply, rather than writing to the database directly.
How do I call an Epicor Function from custom code?
In a BPM use the Call Function widget. From outside Epicor use the REST efx endpoint. For code inside another function, call it through the function call widget or the generated service your release provides.
Can I schedule an Epicor Function?
Yes, but the mechanism depends on your release. A reliable approach is an external scheduler that calls the REST endpoint with an API key. Check your version's release notes for native scheduling options.
Should a function use SQL?
Prefer business objects for writes. Read-only queries can use BAQs or the data widgets. Direct SQL writes skip validation and are not supported for standard tables.
Related
How to create and call an Epicor Function
Open Function Studio from the main menu (Customization > Function Studio) or from inside a BPM designer's Call Context widget, define a Library and Function with typed inputs/outputs, write the logic in the C# widget, then compile and test with the built-in test harness before calling it from a BPM directive, a dashboard, or another function.
How-toHow to Debug Epicor Functions (Logging, Testing, Maintenance)
Debug an Epicor Function by testing it in isolation with known input, writing explicit log entries from a code block, and reading the server trace log for the failing step. Keep libraries maintainable by naming functions clearly, documenting parameters, and managing security and versions in Epicor Functions Maintenance.
How-toEpicor REST API v2: OData Filter, Select and Expand Examples
Epicor Kinetic REST v2 exposes business objects at /api/v2/odata/{Company}/{Service}/{Entity} and BAQs at /api/v2/odata/{Company}/BaqSvc/{BAQId}/Data. Send an API key in the x-api-key header plus credentials, and use standard OData options: $filter, $select, $top, $skip, $orderby and $expand.
How-toEpicor BPM Send Email: Widget, Function and SMTP Setup
To send email from an Epicor Kinetic BPM or Epicor Function, make sure the server SMTP settings work, then add a Send Email widget to the directive or function and fill the To, Subject, Body and optional attachment. Test the SMTP path first with a standard email-producing action, because most failures are server mail settings, not the widget.
Error fixFixing Epicor BusinessObjectException: BPM Directive Errors
A BusinessObjectException that says "A Business Process Management (BPM) directive has raised the following error" means a directive on that business object stopped the transaction, either deliberately via a Raise Exception widget or accidentally via an unhandled .NET error in Custom Code. Expand the InnerException on the error dialog to see the real message and the directive name, then open BPM Designer for that object and method to find the widget that fired.
How-toFixing a Slow Epicor BAQ (Business Activity Query)
A slow BAQ in Epicor is usually caused by unindexed join columns, a subquery or calculated field forcing a table scan, or the BAQ pulling far more rows than the dashboard actually displays before filtering client-side. Fix it by reading the SQL Server execution plan Epicor generates, moving filters into the BAQ criteria instead of the dashboard filter panel, and replacing subqueries with joins where possible.
AI for ERPAI for Epicor Kinetic, Beyond What Prism Covers
Add AI to Epicor Kinetic beyond Prism: private LLM over BAQs, BPM data, and REST v2, on-prem or private cloud, with honest guidance on when Prism already covers you.
AI for ERPPrivate AI for Epicor Kinetic Cloud, Outside the Multi-Tenant Boundary
Run a private LLM on Epicor Kinetic private cloud or Kinetic Cloud data via BAQs, REST v2 and Data Fabric, keeping sensitive manufacturing data off shared AI.
Stuck on Epicor Kinetic?
Talk to engineers who work inside Epicor Kinetic every week, and who build private AI that answers these questions from your own ERP data.
Keep exploring
Free tools
- Epicor Function Library Design TemplateA design document for an Epicor function: signature, inputs, outputs, logic notes, security, test cases and sign off.
- Epicor Kinetic Customization Change Request Form TemplateA fill-in change request form for Application Studio customizations, BPM directives and Epicor Functions, with test and rollback sections.
- Epicor Kinetic BPM Directive Inventory WorksheetAn editable register of your Epicor directives with owner, purpose, risk score and review date, exportable to Excel.
ERP fixes and how-tos
- Epicor Function Custom Code: C# Signature, Parameters and Calling ItWrite custom C# code in Epicor Functions: signature, request and response parameters, libraries, calling from BPM and Application Studio, with working examples.
- How to create and call an Epicor FunctionHow to create Epicor Functions in Function Studio: define inputs and outputs, write the C# widget, test, then call the function from a BPM directive.
- Epicor Function: How to Call a BAQ from C# (Functions and BPM)How to call a BAQ from an Epicor Function or BPM using the DynamicQuery service in C#, pass parameters, read the results and avoid common errors.
AI on your ERP
- AI for Epicor Kinetic Job Shops: Quote History, Job Variance and Schedule RiskPrivate AI for Epicor Kinetic job shops: quote-to-job history, JobHead and JobOper variance, subcontract delays and schedule risk, via REST and BAQs.
- AI for Epicor Kinetic, Beyond What Prism CoversAdd AI to Epicor Kinetic beyond Prism: private LLM over BAQs, BPM data, and REST v2, on-prem or private cloud, with honest guidance on when Prism already covers you.
Integrations
- How to add WhatsApp to Epicor KineticHow to connect WhatsApp Business to Epicor Kinetic: REST and BPM triggers, template messages, opt-in rules and two-way replies that post back to the ERP.
- How to add a mobile app to Epicor KineticBuild or choose a mobile app for Epicor Kinetic: barcode scanning, labor reporting, inventory moves and approvals over the REST API, with offline handling.