1. Overview
Precommit triggers are server-side EKL scripts executed before an object is saved.
They are primarily used for:
- Validation
- Data control
- Enforcing business rules
These triggers operate directly on database-level objects (ThisObject) within the EKL server environment.
2. Where to Configure
Precommit triggers are configured in:
- Data Setup Application
- Resource Set: ER Generic Server Openings
Important
Deprecated: <i>Business Logic for Validation on Server Side (Not available in: Data Model Customization)</i>
Recommended: <strong>ER Generic Server Openings</strong>3. Core Use Cases
Validation and Control
Precommit triggers are also used for:
- Validating user roles, organization, or project
- Preventing invalid actions before saving
- Enforcing business rules
Execution Behavior
By default, triggers run for all roles, organizations, and projects (global execution).
To restrict execution, explicitly check the user context.
Example: Role-Based Logic
Let LoginRole(String)
Let LoginProject(String)
Let LoginOrganization(String)
LoginRole = Parameters.GetAttributeString("Role")
LoginProject = Parameters.GetAttributeString("Project")
LoginOrganization = Parameters.GetAttributeString("Organization")
if ((LoginRole == "VPLMAdmin") or
(LoginRole == "VPLMProjectAdministrator") or
(LoginRole == "VPLMProjectLeader"))
{
Trace(1,"LoginRole-LoginProject-LoginOrganization",
LoginRole, LoginProject, LoginOrganization)
// Output: VPLMProjectAdministrator , PJP3_CollabSpace , Company Name
}
4. Accessing and Modifying Attributes
Attribute Access
Always use the full attribute path:
ThisObject.GetAttributeString("PLMEntity.PLM_ExternalID")Setting Attribute Values
ThisObject.SetAttributeString("XP_CreateAssembly_Ext.Certification", "Approved")Access Hidden Attributes
ThisObject.GetAttributeString("logicalid")
ThisObject.GetAttributeString("physicalid")
5. Retrieving Children of a DELFmiFunctionReference
Context
In ER Generic Server Openings, the standard EKL attribute:
Childrendoes not work.
Recommended Approach
Use:
- GetRelationships()
- GetTo()
- GetFrom()
Data Model Insight
Two DELFmiFunctionReference objects are connected via DELFmiFunctionIdentifiedInstance relationship
This represents a parent-child structure
A way to verify relationships in an OnPremise environment is by using an MQL dump.
Code: Retrieve Children
GetTo() is used to fetch the reference of the instance
GetFrom() is used to fetch the parent of the instance
GetRelationships("Rel Type") is used to fetch the children of the object
// In this script we have called GetRelationships(), GetTo() and GetFrom() as well.
// ThisObject -> DELFmiFunctionReference
Let relList (List)
Let rel (RelationType)
Let fromObj (DELFmiFunctionReference)
Let toObj (DELFmiFunctionReference)
Let i (Integer)
Validation = true
Set relList = ThisObject.GetRelationships("DELFmiFunctionIdentifiedInstance")
if (relList <> NULL)
{
Trace(1, "Number of relationships found: ", relList.Size())
set i = 1
for i while i <= relList.Size()
{
set rel = relList.GetItem(i)
if (rel <> NULL)
{
set fromObj = rel.GetFrom()
set toObj = rel.GetTo()
if (fromObj <> NULL)
{
Trace(1, "FROM Object: ", fromObj.PLM_ExternalID)
}
if (toObj <> NULL)
{
Trace(1, "TO Object: ", toObj.PLM_ExternalID)
}
}
}
}
else
{
Trace(1, "No relationships found")
}
6. Reporting Messages to the User
When you work with precommit triggers, you are provided with the ReportUXMessage function.
Be careful, as stated in the documentation above, using this function is not always sufficient to actually display the message you want to the end user. It depends on the app you are working in.
Note:
All ER Generic Server Openings are executed on the Server side. Therefore, ensure that the the EKL functions used in the business rule are available on the Server side EKL.
For example: ListDocument() EKL API is only available on the Client side of EKL. If you attempt to use this API in the ER Generic Server Openings business rule, you will encounter a syntax error as shown below:
7. Limitations
Some of the limitations are:
- Pattern matching is not available - Requires custom logic/workarounds
- Behavior differs between:
- EKL Client
EKL Server
You can explore this page for more info
8. Best Practices & Important Notes
- Always perform object type checks
- Always use full attribute paths
- Validate inputs before applying logic
- Always check for NULL values
- Combine checks, overrides, and actions
- Avoid unintended global impact (triggers run broadly)
- Test thoroughly in Development or Sandbox before Production
Use Precommit triggers only where necessary
9. Reference Links
Server-Side EKL Functions
ER Generic Server EKL Functions
