IndoTech
4th August 2017, 13:14
Hi

When exactly these User exit functions get executed or what exact difference between these functions or when to use which UE function?

1) ue.before.before.save.object(long mode) and

2) ue.after.before.save.object(long mode)

Regards
Kedar

bdittmar
4th August 2017, 13:59
User Exit DLL Overview
Overview

A User Exit DLL (UEDLL) is a DLL that will reside outside the standard software. It will have the same name as a standard DAL with the extension 'ue' (for 'user exit'). E.g. 'whinh200ue' for table whinh200. Customers can implement a UEDLL in order to be able to define extra business logic before and after the standard 'before' and 'after' handling of saves and deletes, by means of specific hooks that will be executed by the 4GL engine and/or DAL Engine. In this way it is possible to e.g. conditionally publish data changes to the outside world.

Interaction with 4GL Engine / DAL Engine

When present, the User Exit DLL for a certain table will be loaded by the 4GL engine/DAL Engine by the time the DAL for this particular table will be loaded. In situations where no DAL is present this will be the moment at which a DAL would be loaded if it existed. This means that there is no need to have a DAL in order to make use of the UEDLL.

Preconditions

A DLL becomes a UEDLL when it meets the following conditions:

Its name is consisting of the table code with 'ue' as suffix, like whinh200ue
It includes bic_dal, as follows: #include <bic_dal>
Restrictions

A UEDLL is treated like a regular DAL. This means all kind of DAL related functionality can be used, like:

Function with.old.object.values.do()
Function with.object.set.do()
Pre-defined variable subdal
Note however that the following restrictions apply:

Business methods cannot be implemented in a UEDLL Instead the business logic should be programmed in another (separate) general DLL.
It is strongly discouraged to define other external functions in a UEDLL and link the UEDLL directly to other scripts. Instead, use a normal general DLL. (This also applies to regular DALs).
User Exit Hooks

A UEDLL script can contain the following hooks:

ue.before.before.save.object()
ue.after.before.save.object()
ue.before.after.save.object()
ue.after.after.save.object()
ue.before.before.destroy.object()
ue.after.before.destroy.object()
ue.before.after.destroy.object()
ue.after.after.destroy.object()
Related topics


ue.before.before.save.object()
Syntax:

function extern long ue.before.before.save.object ( [long mode])

Description


This hook is called in case data is saved, either by the user pressing the save button on the UI, or programmatically when one of the functions dal.save.object(), dal.new(), or dal.update() is called.

Note that this hook is not executed in case a db.insert() or a db.update() is done.

In case a DAL is present, this hook is executed just before the before.save.object() hook.

In case no DAL is present, this hook is executed just before the main.table.io:before.write: and main.table.io:before.rewrite: UI script sections.


Arguments

[long mode ] This parameter contains either the value DAL_NEW in case of an insert, or DAL_UPDATE in case of an update.


Return values

This hooks returns 0 if saving the record is permitted. It should return a negative value like DALHOOKERROR, in case of an error.

Context

This function can be used in UEDLL script types.




ue.after.before.save.object()
Syntax:

function extern long ue.after.before.save.object ( [long mode])

Description


This hook is called in case data is saved, either by the user pressing the save button on the UI, or programmatically when one of the functions dal.save.object(), dal.new(), or dal.update() is called.

Note that this hook is not executed in case a db.insert() or a db.update() is done.

In case a DAL is present, this hook is executed just after the before.save.object() hook.

In case no DAL is present, this hook is executed just after the main.table.io:before.write: and main.table.io:before.rewrite: UI script sections.


Arguments

[long mode ] This parameter contains either the value DAL_NEW in case of an insert, or DAL_UPDATE in case of an update.


Return values

This hooks returns 0 if saving the record is permitted. It should return a negative value like DALHOOKERROR, in case of an error.

Context

This function can be used in UEDLL script types.