BusinessObject

Simplicite.Ajax. BusinessObject

new BusinessObject(app, objName, objInstName)

Simplicité® business object.
Getting a new business object should use the Simplicite.Ajax.getBusinessObject() function instead of this constructor

Parameters:
Name Type Description
app

Application Simplicite.Ajax instance

objName

Object name

objInstName

Object instance name, optional (defauts to ajax_<object name>)

Members

count

Current search result count.

crosstabdata

Current cross table data.

filters

Current search filters. Use filters["<field name>"] or filters.<field name> to access to the filter value

item

Current item. Use item["<field name>"] or item.<field name> to access to the field value

list

Current search result array of items.

locals

Local parameters

maxpage

Current search result max page index (for paginated searches).

metadata

Current meta data.

  • name: object name
  • instance: object instance name
  • fields: fields definition array
  • Etc.

page

Current search result page index (for paginated searches).

Methods

action(callback, act, params)

Calls an object action and loads action result.

Parameters:
Name Type Description
callback

Callback function({ data, redirect: {url, target} })

act

Action name

params

Optional parameters :

  • values: object of field/value
  • metadata: true to update the metadata in context UPDATE on form action or LIST on list action
  • init: true to initAction only on server side and get Action fields metadata
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?

addItem(item, index)

Add item to list

Parameters:
Name Type Description
item

list item

index

optional creation index 00 01...

completion(callback, field, req, params)

Calls an object completion for specified field and loads action result.

Parameters:
Name Type Description
callback

Callback function called when loading is completed (completion result is passed to this function)

field

Field name

req

Completion request

params

Optional parameters :

  • max Optional max size, default 15
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?

create(callback, item, params)

Creates and loads an item.

Parameters:
Name Type Description
callback

Callback function called when loading is completed

item

Item to be created (row ID field of the item must be set to Simplicite.Ajax.DEFAULT_ROW_ID), optional (if absent current item is used)

params

Optional parameters :

  • inlineDocs Inline documents (true | 'images' only | 'infos' without content | array of fields) ?
  • inlineThumbs Inline image documents thumbnails (true | array of fields) ?
  • inlineObjs Inline objects fields items (true|false) ?
  • metadata: true to update the metadata in context UPDATE when created
  • target: true to get target object if any
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?
  • progress Optional progress callback

crosstab(callback, ctb, filters, params)

Loads cross table data for search filters.

Parameters:
Name Type Description
callback

Callback function called when loading is completed

ctb

Cross table name

filters

Filters to be applied, optional (if absent, current filters are used)

params

Optional parameters :

  • ztree get lines tree with sums and metadata
  • zstotal get sub-totals ?
  • zstcolor sub-totals color
  • zaxis change axis ordering [\{name, order, type, method\}]
  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?

del(callback, item, params)

Deletes item. Current item is set to undefined.

Parameters:
Name Type Description
callback

Callback function called when loading is completed

item

optional item to be deleted or rowId (if absent current item is used)

params

Optional parameters :

  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?

deleteAll(callback, params)

Deletes all (selected) items.

Parameters:
Name Type Description
callback

Callback function called when deletion is completed

params

Optional parameters :

  • async Asynchronous call (use default if absent) ?
  • error Custom error handler (use default error handler if absent) ?

get(callback, rowId, params)

Selects and loads an item for designated row ID (if row ID is Simplicite.Ajax.DEFAULT_ROW_ID, a defaut item for creation is returned with all default values applied).

Parameters:
Name Type Description
callback

Callback function called when loading is completed

rowId

Row ID, mandatory

params

Optional parameters object may include:

  • context: Init context (one of Simplicite.Ajax.CONTEXT_CREATE/UPDATE/DELETE/COPY constants)
  • metadata: true to update the metadata in context
  • inlineDocs: Inline documents (true or 'images' for images only or 'infos' for documents data without content or array of field names) ?
  • inlineThumbs: Inline image documents thumbnails (true | array of fields) ?
  • inlineObjs: Inline objects fields items (true|false) ?
  • fields: Array of field names to retrieve (if absent or undefined, all fields are retrieved)
  • parent: optional parent context \{name,inst,field,rowId\} to populate related fields (useful in CONTEXT_CREATE)
  • values: Optional field values to set and foreign keys to populate
  • async: Asynchronous call (use default if absent or undefined) ?
  • error: Custom error handler (use default error handler if absent) ?
  • social: true to get posts count
  • share: true to get social share data
  • treeView: optional treeview name
  • treeDepth: search depth in tree
  • treeHistory: true update and get the user's trees history
  • treePath: optional tree path

    getAction(name)

    Get action definition

    Parameters:
    Name Type Description
    name

    Action name

    getAgenda(name)

    Get agenda definition

    Parameters:
    Name Type Description
    name

    Agenda name

    getArea(n)

    Get area definition

    Parameters:
    Name Type Description
    n

    Area position

    getCount(callback, filters, params)

    Count rows with filters and set count and maxpage in object.

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed

    filters

    Filters to be applied, optional (if absent, current filters are used)

    params

    Optional parameters { parent, view, metadata }

    getCrosstab(name)

    Get crosstab definition

    Parameters:
    Name Type Description
    name

    Crosstab name

    getCrosstabCubes(callback, name, params)

    Get crosstab cubes (data)

    Parameters:
    Name Type Description
    callback

    function(cubes)

    name

    Crosstab name

    params

    Optional async and error handler

    getDisplay()

    Get display label

    getField(name, id)

    Gets field from fields array in meta-data (returns undefined if field is not found).

    Parameters:
    Name Type Description
    name

    Field name or Field

    id

    Optional list index/rowId

    getFieldArea(n)

    Get field area definition

    Parameters:
    Name Type Description
    n

    Area name or position

    getFieldIndex(name)

    Gets the field index in object

    Parameters:
    Name Type Description
    name

    Field name or Field

    getFieldOldValue()

    Get old field value shorthand

    getFields()

    Gets fields array from meta data (is undefined as long as meta data are not loaded using getMetaData).

    getFieldValue(name, id)

    Get field value shorthand

    Parameters:
    Name Type Description
    name

    Field name or Field

    id

    Optional list rowId

    getFilters(callback, params)

    Loads current filters.

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed

    params

    Optional parameters :

    • context Init context (normally Simplicite.Ajax.CONTEXT_SEARCH constant), optional
    • reset Reset filters, optional
    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?

    getFiltersForSearch(callback, params)

    Loads current filters for search (equivalent to a getFilters done with the search init context Simplicite.Ajax.CONTEXT_SEARCH).

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed

    params

    Optional parameters

    getForCopy(callback, rowId, params)

    Loads item for designated row ID for copy (equivalent to a get done with the copy init context Simplicite.Ajax.CONTEXT_COPY).

    Parameters:
    Name Type Description
    callback

    Callback function called when loading and context initialization is completed

    rowId

    Row ID, mandatory

    params

    Optional parameters (same as for get function)

    getForCreate(callback, params)

    Loads default item for creation (equivalent to a get done on default row ID with the create init context Simplicite.Ajax.CONTEXT_CREATE).

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed

    params

    Optional parameters (same as for get function)

    getForDelete(callback, rowId, params)

    Loads item for designated row ID for delete (equivalent to a get done with the delete init context Simplicite.Ajax.CONTEXT_DELETE).

    Parameters:
    Name Type Description
    callback

    Callback function called when loading and context initialization is completed

    rowId

    Row ID, mandatory

    params

    Optional parameters (same as for get function)

    getForeignKeys()

    Get foreign-key fields

    getForUpdate(callback, rowId, params)

    Loads item for designated row ID for update (equivalent to a get done with the update init context Simplicite.Ajax.CONTEXT_UPDATE).

    Parameters:
    Name Type Description
    callback

    Callback function called when loading and context initialization is completed

    rowId

    Row ID, mandatory

    params

    Optional parameters (same as for get function)

    getHelp()

    Gets context help from meta data (is undefined as long as meta data are not loaded using getMetaData).

    getId()

    Gets Id from meta data.

    getImageURL(item)

    Get URL of first image field

    Parameters:
    Name Type Description
    item Object

    optional item (use field values if unset)

    getInstance()

    Gets instance name from meta data.

    getInstanceName()

    Gets instance name from meta data (alias to getInstane).

    getItem(id)

    Gets the current item

    Parameters:
    Name Type Description
    id

    Optional index/rowId to look in current list

    getLabel()

    Gets label from meta data (is undefined as long as meta data are not loaded using getMetaData).

    Gets a link definition.

    Parameters:
    Name Type Description
    object

    Referenced object or name

    field

    Foreign key field or name

    getLinkedList(field, value, target, lov, callback, params)

    Gets a linked list of an enum field

    Parameters:
    Name Type Description
    field

    Enum field name

    value

    Selected value(s) separated with ";"

    target

    Linked field

    lov

    Current linked list name

    callback

    function(target, new list {name, items})

    params

    Optional async and error handler

    Properties
    Name Type Description
    all

    Get all linked values when value is empty

    Gets links array from meta data (is undefined as long as meta data are not loaded using getMetaData).

    getListItem(i)

    Gets item in the current list

    Parameters:
    Name Type Description
    i

    index

    getListPos(rowId)

    Gets the position in current list, -1 if not found

    Parameters:
    Name Type Description
    rowId

    row Id to find

    getListValue(list, code)

    Gets value from list for specified code (returns undefined if code is not in list).

    Parameters:
    Name Type Description
    list

    List metadata (typically from a field metadata)

    code

    Code

    getMetaData(callback, params)

    Loads meta data for specified context.
    Sample usage:

    Example
    obj.getMetaData(function() {
      alert("Meta data loaded for update of object " + this.getName());
    }, { context: app.CONTEXT_UPDATE });
    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed

    params

    Optional parameters :

    • context Context (one of Simplicite.Ajax.CONTEXT_* constants)
    • contextParam Context single parameter (agenda name...)
    • parent Parent of PANELLIST \{ name, inst, field, rowId \}
    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?

    getName()

    Gets name from meta data.

    getObjectField(f, data)

    Gets an Object Field

    Parameters:
    Name Type Description
    f string | Simplicite.Ajax.ObjectField

    Field name or metadata

    data Object

    Optional contextual data { value, message }

    getObjectParameter()

    Get object parameter (unused but kept for forward compatibility because of deprecated synchronous usage)

    getOldValues()

    Get old values

    getParameter(callback, name, params)

    Loads an object parameter.

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed (parameter is passed to this function)

    name

    Parameter name

    params

    Optional parameters :

    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?

    getParent()

    Get parent object

    getParentObject()

    Get parent business object of panel instance

    getParentObjectRefField()

    Get foreign key of panel instance

    getPivotTable()

    Alias for getCrosstab

    getPivotTableData()

    Alias for getCrosstabCubes

    getPlacemap(name)

    Get placemap definition

    Parameters:
    Name Type Description
    name

    Placemap name

    getPrintTemplate(name)

    Get print definition

    Parameters:
    Name Type Description
    name

    Print template name

    getRootField(field)

    Get the root field of reference, null when field belongs to object

    Parameters:
    Name Type Description
    field

    Field or name

    getRowId()

    Gets current item row Id value (returns undefined if not current item is loaded).

    getRowIdField()

    Gets row Id field from meta data (returns undefined if row Id field name is undefined).

    getRowIdFieldName()

    Gets row Id field name from meta data (is undefined as long as meta data are not loaded using getMetaData).

    getStatusField()

    Get status field

    getTransition(name)

    Get transition definition

    Parameters:
    Name Type Description
    name

    Transition name

    getUserKeyFields()

    Get user-key fields

    getValueForCode(field, code)

    Gets list of values field value from code (returns code if not found or not a list of value field)

    Parameters:
    Name Type Description
    field

    Field

    code

    Field code

    getValues()

    Get values (fields into item)

    getView(name)

    Gets a view definition.

    Parameters:
    Name Type Description
    name

    View name

    getViews()

    Gets views array from meta data (is undefined as long as meta data are not loaded using getMetaData).

    help(callback, params)

    Gets the long help.

    Parameters:
    Name Type Description
    callback

    Callback function called

    params

    Optional parameters :

    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?

    indexsearch(callback, request, params)

    Search from index and loads search result items.

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed

    request

    Index search request string

    params

    Optional parameters :

    • inlineDocs Inline documents (true | 'images' only | 'infos' without content | array of fields) ?
    • inlineThumbs Inline image documents thumbnails (true | array of fields) ?
    • inlineObjs Inline objects fields items (true|false) ?
    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?
    • context optional context
    • parent optional parent \{ name, inst, field, rowId \} to search references
    • filters optional linkmap filters to limit search

    isAjaxInstance()

    Is ajax instance?

    isChildOf()

    Is child of?

    isCopied()

    Is copied record?

    isDataMapInstance()

    Is datamap selection instance?

    isDataMappedFrom()

    Is data-mapped from?

    isFiltered(exclude)

    Is object filtered ?

    Parameters:
    Name Type Description
    exclude field:value

    Optional filters to ignore

    isHomeInstance()

    Is home instance?

    isLoaded()

    Are metadata loaded ?

    isMainInstance()

    Is main instance?

    isNew()

    Is new record?

    isOrdered()

    Is object ordered ?

    isPanelInstance()

    Is panel instance?

    isPanelOf()

    Is panel of?

    isProcessInstance()

    Is process instance?

    isReferencedFrom()

    Is referenced from?

    isRefInstance()

    Is reference selection instance?

    isRowIdField(f)

    Checks whether a field is the row ID field.

    Parameters:
    Name Type Description
    f

    Field meta data

    isTimestampField(f)

    Checks whether a field is a timestamp field.

    Parameters:
    Name Type Description
    f

    Field meta data

    isTmpInstance()

    Is temporary instance?

    localParameter(name, value)

    Local parameter in object instance

    Parameters:
    Name Type Description
    name

    Parameter key name

    value

    Optional value (to get or set)

    merge(callback, data, params)

    Service to merge items

    Parameters:
    Name Type Description
    callback function

    optional callback

    data Object

    merge data

    Properties
    Name Type Description
    ids Array

    array of row IDs to merge

    check Array

    true to check only (isMergeEnable)

    item Object

    index per field to preserve

    links Object

    indexes per link to preserve

    metaobj Object

    indexes per meta-object to preserve

    params Object

    optional parameters { async, error }

    placemap(callback, pcm, filters, params)

    Calls an object place map and loads places datat.

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed (places data result is passed to this function)

    pcm

    Place map name

    filters

    Optional filters to apply (if absent, current filters are used)

    params

    Optional parameters :

    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?

    populate(callback, item, params)

    Populate item (e.g. after getForCreate and after having set foreign keys)

    Parameters:
    Name Type Description
    callback function

    function(item) callback with populated item

    item Object

    Item to be populated, optional (if absent current item is used)

    params Object

    Optional parameters:

    Properties
    Name Type Description
    inlineDocs boolean | string | Array

    Inline documents: true | 'images' only | 'infos' without content | array of fields

    inlineThumbs boolean | Array

    Inline image documents thumbnails: true | array of fields

    inlineObjs boolean

    Inline objects fields items

    userKeys boolean

    Get foreign user-keys

    async boolean

    Asynchronous call (use default if absent or undefined)

    error function

    Custom error handler (use default error handler if absent)

    predefSearch(callback, method, ps, params)

    Predefined search service (of user's private searches, public searches are protected)

    Parameters:
    Name Type Description
    callback

    Callback function

    method

    create|update|delete

    ps

    Predefined search to save { id, name, filters }

    params

    { async, error }

    preferences(callback, prefs, params)

    Preferences service.

    Parameters:
    Name Type Description
    callback

    Callback function

    prefs

    optional preferences to save { list, search, actions }

    params

    Optional parameters :

    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?

    print(callback, prt, params)

    Calls an object publication and loads publication result.

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed (publication result is passed to this function)

    prt

    Print template name

    params

    Optional parameters :

    • all Apply template to all items matching current filters (false by default, which means apply template only to current item) ?
    • mailing Apply template individually to all items matching current filter (false by default) ?
    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?

    remove()

    Same as del function

    removeArea(n)

    Remove area in metadata if position exists

    Parameters:
    Name Type Description
    n

    Area position

    removeItem(id)

    Remove item from list

    Parameters:
    Name Type Description
    id

    index/rowId in current list

    removeParameter(callback, name, params)

    Remove an object parameter.

    Parameters:
    Name Type Description
    callback

    Callback function called when completed

    name

    Parameter name

    params

    Optional parameters :

    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?

    resetFilters()

    Reset filters (not orders and groups)

    resetGroupByFields()

    Reset group by fields

    resetOrders()

    Reset orders (not filters)

    resetValues(old)

    reset values (item into fields)

    Parameters:
    Name Type Description
    old

    true to reset old values

    save(callback, item, params)

    Saves (create or update) and loads an item.

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed

    item

    Item to be saved, optional (if absent current item is used)

    params

    Optional parameters (see create or update method)

    Search and loads search result items.

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed

    filters

    Optional filters to apply (if absent, current filters are used)

    params

    Optional parameters :

    • context Init context (normally one of Simplicite.Ajax.CONTEXT_LIST/PANELLIST/REFSELECT/DATAMAPSELECT/EXPORT/CROSSTAB/GRAPH/PRINTTMPL constant), optional
    • metadata: true to update the metadata in context, and items with \{ meta:\{...\}, data:\{...\} \}, false to get the data directly
    • page Page index to retrieve (between 0 and maxpage), optional (if absent or set to -1 no pagination will be done, for pagination a first call must be done with pageIndex set to 0)
    • inlineDocs Inline documents (true | 'images' only | 'infos' without content | array of fields) ?
    • inlineThumbs Inline image documents thumbnails (true | array of fields) ?
    • inlineObjs Inline objects fields items (true|false) ?
    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?
    • parent optional parent object \{ name, inst, field, rowId \} in CONTEXT_PANELLIST
    • view optional view \{ name:viewname, item:position, home:true|false \} in CONTEXT_LIST
    • history true to get rows histories
    • totals true to get the field aggregations
    • social true to get posts count for each row
    • visible true to get only visible fields
    • edit optional edit list mode 'new', 'rows' or 'upsert'
    • groupby true to get the group by result
    • partial true to get result for lazy-loading without changing the object data

    searchForList(callback, filters, params)

    Search and loads search result items for list (equivalent to a search done with the list init context Simplicite.Ajax.CONTEXT_LIST).

    Parameters:
    Name Type Description
    callback

    Callback (function called when loading is completed)

    filters

    Filters to be applied, optional (if absent, current filters are used)

    params

    Optional parameters

    searchForPanelList(callback, filters, params)

    Search and loads search result items for panel list (equivalent to a search done with the list init context Simplicite.Ajax.CONTEXT_PANELLIST).

    Parameters:
    Name Type Description
    callback

    Callback (function called when loading is completed)

    filters

    Filters to be applied, optional (if absent, current filters are used)

    params

    Optional parameters

    • parent optional parent object \{ name, inst, field \} in CONTEXT_PANELLIST

    select()

    Same as get function

    selectForCopy()

    Same as getForCopy function

    selectForCreate()

    Same as getForCreate function

    selectForDelete()

    Same as getForDelete function

    selectForUpdate()

    Same as getForUpdate function

    selectRow(sel, callback, params)

    Select row(s).

    Parameters:
    Name Type Description
    sel

    all, page, none or specific row IDs (single or array or semicolon-separated)

    callback

    function(ids)

    params

    Optional async and error handler

    Properties
    Name Type Description
    replace

    true to replace all selection

    setCrosstab(name, meta)

    Set crosstab definition

    Parameters:
    Name Type Description
    name

    Crosstab name

    meta

    Crosstab metadata

    setFieldOldValue()

    Set old field value shorthand

    setFieldValue(name, val, id)

    Set field value shorthand

    Parameters:
    Name Type Description
    name

    Field name or Field

    val

    Value

    id

    Optional list rowId

    setList(field, list, callback, params)

    Set a new list to field, does nothing when new list is the same.

    Parameters:
    Name Type Description
    field

    Enum field name

    list

    List name to load

    callback

    function(field,newList)

    params

    Optional async and error handler

    setListSize(callback, size, params)

    Sets the search size for pagination.

    Parameters:
    Name Type Description
    callback

    Callback function called when completed

    size

    Integer value

    params

    Optional parameters :

    setParameter(callback, name, value, params)

    Sets (or remove) an object parameter and loads it back.

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed (parameter is passed to this function)

    name

    Parameter name

    value

    Parameter value (unset if null)

    params

    Optional parameters :

    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?

    setParent()

    Store parent object in panel instance { name, inst, field, rowId, object }

    setPivotTable()

    Alias for setCrosstab

    setRowId()

    Sets current item row Id value.

    setValues(item, old, id)

    Set values (item into fields)

    Parameters:
    Name Type Description
    item

    values per field name, default: current item

    old

    true to copy values into old values ?

    id

    optional list index/rowId

    timesheet(cbk, data, params)

    Timesheet service

    Parameters:
    Name Type Description
    cbk function

    optional callback(timesheet)

    data Object

    timesheet data { name, resId }

    params Object

    optional parameters { async, error }

    update(callback, item, params)

    Updates and loads an item.

    Parameters:
    Name Type Description
    callback

    Callback function called when loading is completed

    item

    Item to be updated, optional (if absent current item is used)

    params

    Optional parameters :

    • inlineDocs Inline documents (true | 'images' only | 'infos' without content | array of fields) ?
    • inlineThumbs Inline image documents thumbnails (true | array of fields) ?
    • inlineObjs Inline objects fields items (true|false) ?
    • metadata: true to update the metadata in context UPDATE
    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?
    • context optional to specify when update occurs on a LIST
    • progress Optional progress callback
    • timestamp false to bypass timestamp check and update (silent update)
    • itemAction optional action parameters of transition

    updateAll(callback, item, params)

    Updates all (selected) items.

    Parameters:
    Name Type Description
    callback

    Callback function called when update is completed

    item

    Item to be updated, optional (if absent current item is used)

    params

    Optional parameters :

    • async Asynchronous call (use default if absent) ?
    • error Custom error handler (use default error handler if absent) ?
    • progress Optional progress callback