# Epicor Function Examples: Update a Table, Call It, Schedule It

> Source: https://netray.co/erp-help/epicor-function-examples-update-table-call-schedule
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: ERP Help

## 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.

## Kind

advanced

## System

epicor

## Erp

Epicor Kinetic

## Module

Epicor Functions

## Query

epicor function examples

## Alternate Queries

- epicor function update table
- epicor call function from code
- epicor schedule function

## Applies To

Epicor Kinetic 2021 and later with Epicor Functions; REST path shown for the v2 API

## Steps

### How to build, call and schedule a function

**Items:**

- Create a library in Epicor Functions Maintenance and add a function with a clear name such as UpdateJobNote.
- Define input parameters (for example JobNum as string, Note as string) and output parameters (for example Result as string).
- In 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.
- Add a Condition and error handling so a missing record returns a meaningful result instead of an exception.
- Save and enable the function and set security so only the right users or integration account may call it.
- Call it from a BPM with a Call Function widget, from Application Studio with a function call action, or from outside with REST.
- For recurring work, trigger it from a scheduler that calls the REST endpoint, or use the scheduling capability your release provides.
- Log the outcome and test with sample input before enabling the schedule.

## Sections

### Updating a table the supported way

**Body:**

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

**Body:**

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.

**Code:**

- POST https://yourserver/yourinstance/api/v2/efx/COMPANY/MyLib/UpdateJobNote
Content-Type: application/json

{ "jobNum": "J0001", "note": "Rush" }

### Scheduling a function

**Body:**

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.

## 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.

## Ai Angle

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.

## Faq

### Can an Epicor Function update a UD table?

**Answer:** 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?

**Answer:** 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?

**Answer:** 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?

**Answer:** 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.

## Search terms

epicor function examples, epicor function update table, epicor call function from code, epicor schedule function, epicor efx rest api, epicor kinetic functions, epicor call function from bpm, epicor function library example

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
