The BO Function Handler
reviewed: 22 February 2025
The second-most important function handler is no doubt the BO function handler (the most important handler is the default handler).
See also here.
Typical Scenarios
Creating a new BO
The following sequence is typically how you create a new instance of a BO.
bo.create()will create and return a handle to a new BO for a given entity.bo.reset()will reset all attributes of a BO to their default valuebo.setAutomatics()will assign a new value to each attribute of type automatic
set( 'client', bo.create( 'client' ) )
bo.reset( [client] )
bo.setAutomatics( [client] )
You can set attribute values using bo.setAttr():
bo.setAttr( [client], 'firstName', 'Bertus' )
bo.setAttr( [client], 'surName', 'Dispa' )
And you can insert a newly created BO into the database using bo.insert():
bo.insert( [client] )
Loading and Updating a BO
function doTest()
// Load client with PK 10
set( 'client', bo.quickLoad( 'client', 10 ) )
// Set firstName
bo.setAttr( [client], 'firstName', 'B' )
// Update
bo.update( [client] )
end-function
Get / Set Attribute Values
| Function | Use | Details |
|---|---|---|
| anyNotNull | anyNotNull(bo, group) |
Returns True if any attribute in the given group has a non-null value; Else False |
| anyNull | anyNull(bo, group) |
Returns True if any attribute in the given group has a null value; Else False |
| attr | attr(bo, name) |
Retrieve an attribute value from a business object |
| attrFormatted | attrFormatted(bo, name, [culture]) |
Retrieve a formatted attribute value from a business object |
| attrFormattedGroup | attrFormattedGroup(bo, group) |
Retrieve a formatted group of attribute values from a business object |
| bo2bo | bo2bo(from, to, group) |
Copy attributes from one business object to another |
| label | label(bo, [pk]) |
Get the Label group value of a business object from context or by pk |
| nameValuePairs | nameValuePairs(bo, group) |
Returns a list of attributes and values from a business object |
| pk | pk(bo) |
Returns the business objects Primary Key value |
| reset | reset(bo, [group]) |
Reset a business object; sets the attributes to their default value. |
| setAttr | setAttr(bo, name, value) |
Set the value of a business object attribute |
| setAutomatics | setAutomatics(bo, [group]) |
Set automatics of a business object. |
| setTestData | setTestData(bo, [group]) |
Set the test data values of a business object. |
| valueString | valueString(bo, group, [pk]) |
Get the value string for given BO and given group or for BO loaded by given PK |
Database Routines
| Function | Use | Details |
|---|---|---|
| avg | avg(bo, group, [where]) |
Get the average value of the given attribute(s) |
| count | count(bo, [where]) |
Count business objects instances in the database |
| delete | delete(bo, [where]) |
Delete a business object from the data source |
| disconnectWhereClause | disconnectWhereClause(bo, where) |
Disconnect a where clause from the context |
| ensureLoad | ensureLoad(bo, group) |
Ensure that all attributes in group are loaded |
| exists | exists(bo, where) |
Determines if a business object exists in the data source |
| insert | insert(bo) |
Insert a business object into the data source |
| load | load(bo, group, where, [orderBy]) |
Load a business object from the data source |
| loadFK | loadFK(bo, attribute, [group]) |
Load the foreign key business object for the given attribute |
| max | max(bo, group, [where]) |
Get the maximum value of the given attribute(s) |
| min | min(bo, group, [where]) |
Get the minimum value of the given attribute(s) |
| notExists | notExists(bo, where) |
Determines if a business object does not exist in the data source |
| persist | persist(bo) |
Persist a business object into the data source |
| quickLoad | quickLoad(entity, value, [attribute], [group]) |
Load a business object from the data source |
| sum | sum(bo, group, [where]) |
Sum the value of the given attribute(s) |
| tryLoad | tryLoad(entity, where, group, context, [orderBy]) |
Try and load a business object |
| update | update(bo, [group], [where]) |
Update a business object |
| writeAudit | writeAudit(bo, audit, [group]) |
Write an audit for the given business object |
Conversion Functions
| Function | Use | Details |
|---|---|---|
| bo2json | bo2json(bo, [group]) |
Serialize a business object to JSON |
| bo2pb | bo2pb(bo, [group]) |
Serialize a business object to a property bag |
| bo2xml | bo2xml(bo, [group]) |
Serialize a business object to XML |
| json2bo | json2bo(json, [group]) |
Deserialize JSON to a business object |
| pb2bo | pb2bo(bag, [group]) |
Deserialize a property bag to a business object |
| xml2bo | xml2bo(xml, [group]) |
Deserialize XML to a business object |
Live BO's
| Function | Use | Details |
|---|---|---|
| create | create(entity) |
Create a business object |
| inContext | inContext(name, [pk], [entity]) |
Check whether a business object exists in context |
| login | login() |
Gets the current user login business object |
| session | session() |
Gets the current session business object |
| user | user() |
Gets the current user business object |
Methods and Conditions
| Function | Use | Details |
|---|---|---|
| invoke | invoke(bo, function, [{parameters}]) |
Invoke a business object function |
| is | is(bo, condition, [{parameters}]) |
Determine if a business object meets a condition |
Miscelleanous
| Function | Use | Details |
|---|---|---|
| addAttrError | addAttrError(bo, name, message) |
Add an error to the business objects context |
| addError | addError(bo, message) |
Add an error to the business objects context |
| attrPersistStatus | attrPersistStatus(bo, name) |
Retrieve the persist status of an attribute for a given business object |
| canDelete | canDelete(bo) |
Determines if the business object can be deleted |
| canInsert | canInsert(bo) |
Determines if the business object can be inserted |
| canSelect | canSelect(bo) |
Determines if the business object can be loaded |
| canUpdate | canUpdate(bo) |
Determines if the business object can be updated |
| errors | errors(bo) |
Gets a business objects context errors |
| getAlias | getAlias(bo) |
Gets a business objects alias |
| inError | inError(bo) |
Determines if a business object has errors |
| setAlias | setAlias(bo, alias) |
Set a business objects alias |
| zXRqd | zXRqd(bo) |
Determines if a business object is required for system data If the business object has the zXRqd attribute and its value is True, then True; else False |
<End of document>