View
To get the full data of a particular record we will call /view with an paramater id. Now view can be changed to edit or add, and it will change how the permissions of the data are returned.
GET crm/leads/view?id=1811
This will fetch the entire data record for lead with id=1811.
{
"data": {
"leads": {
"created": "2025-01-03 14:32:07",
"created_by": "739",
"first_name": "Test ",
"id": "1811",
"last_name": "LEAD 1",
"lead_source": "898",
"mobile": "9899998988",
"modified": "2025-01-03 14:32:43",
"modified_by": "739",
"people_type_id": "11",
"__people_type_id": "Internal Staff",
}
},
"errors": [],
"message": [],
"primary_key": "id",
"display_field": "name",
"model": "leads",
"model_class": "\\module\\crm\\model\\leads",
"id": "1811",
"is_record_deleted": false,
"permissions": {},
"model_associations": {},
"model_behaviours": {},
"name": "Test Lead 1",
"filterRules": {},
"form": {},
"rebaseline": [],
"allow_comments":1,
"is_editable": 1,
"is_deletable": 0,
"alias": "leads",
"singular": "lead",
"controllerClass": "\\module\\crm\\controller\\leads",
"modelClass": "\\module\\crm\\model\\leads",
"notEmptyField": {},
"user_id": "739",
"user_fullname": "Michael Ilao"
}
The view call will fetch data related to the record as well as meta data about the record and the leads controller in general.
Data
To access the data generically we can use the follow pattern
const json = {...} // above json
const data = json.data[json.model]
The data variable will now contain data pertaining to the lead record 1811.
Associated Data
Data values can be either free inputs like a string, number or boolean. Or it can be associated to another data model.
Take the field people_type_id: 11, this relates a defined people_type to this lead record. The convention for these fields are as follow
{field_name}_idfor the associated id__{field_name}_idfor the associateed name of the field
In this case the lead is of type Internal Staff
These associations are all defined in model_associations, a field on the top level of the object.
{
"model_associations": {
"config_people_types": {
"assocType": "belongsTo",
"className": "\\module\\crm\\model\\config_people_types",
"associationAlias": "config_people_types",
"foreignKey": "people_type_id",
"show_link": "1",
"business_key": "63b073a2-c008-43a1-b091-4c33ac69033c",
"isAclChild": 0,
"isSubModel": 0,
"isSearchable": 0,
"consider_as_submodel_for_deep_cloning": 0,
}
}
}
A model association provides meta data about the association. In this case the association is under the model \\module\\crm\\model\\config_people_types and the foreign key is people_type_id. And what kind of association type it is, belongsTo
Form
The form object is the meta data representing the form associated with the requested record. The form is a tree based data structure that is a structural representation of the inputs, values and listviews that compose a model.
"form": {
"name": "default",
"name_model": "schema",
"__name": "default",
"label": "",
"class": "",
"_container": "0",
"label_class": "",
"info_class": "",
"enctype": "",
"_not_empty": "0",
"description": "",
"permission": 4,
"_is_web_compatible": "0",
"is_web_compatible": "1",
"_is_mobile_compatible": "0",
"is_mobile_compatible": "1",
"formula": "",
"on_change_field": "",
"on_change_field_model": "schema",
"__on_change_field": "",
"mapped_field": "",
"mapped_field_model": "schema",
"__mapped_field": "",
"filter_field": "",
"filter_field_model": "schema",
"__filter_field": "",
"filter_val": "",
"filter_by_fields": "",
"filter_by_fields_model": "schema",
"__filter_by_fields": "",
"model_class": "\\module\\crm\\model\\peoples",
"template": "form",
"children": []
}
Each node in the tree is either a display element or an input element. The root element is always of type form, this contains meta data about the form, but most importantly contains a field called children, which contains the children nodes,
Display
Display are elements that dictate how a set of inputs should be structured. For example a collection place child elements inline, while block, stacks them on top of eachother.
block
tab
collection
grid
menu
panel
subform
...
Input
Input elements are what control the behaviour and values of the data fields on a record.
input
number
popup
textarea
file
radio
select
...
Inputs have keys name and label. name is the id of the input from the record in the form of an array. In the case below to access the value for this input, we will look in the data records at peoples.people_type_id. Other useful information to help build the input is under tooltip and help. Which is the text descibing what this input is to users.
{
"name": [
"peoples",
"people_type_id"
],
"__name": "peoples.people_type_id",
"label": "people_type_id",
"tooltip": "For a Partner (either Channel Partner, Referral Partner, Affiliate, or Franchisee) please select ALLOW PORTAL ACCESS. This creates a USER for them in the system, which is required for you to select them as the Referral Agent. Further, you should only Send them Portal Login if they have been authorized for Portal Use.",
"help": "For Partner, select ALLOW PORTAL ACCESS and do not select SEND PORTAL LOGIN EMAIL",
"on_change_reload_form": "1",
"inline_search": "1",
"is_web_compatible": "1",
"is_mobile_compatible": "1",
"select": "1",
"open": "1",
"helper": "\\kernel\\form",
"method": "popup",
"show_model": "0",
"show_link": "0",
"concat_text_value": "0",
"postfix_label": "0",
"prefix_id": "0",
"allow_copy_to_clipboard": "0",
"disable_autofill_while_cloning": "0",
"allow_user_to_specify_user_level_default": "0",
"business_key": "651b5b54-d290-4cb8-9e25-4f1fac69033c",
"template": "popup",
"packaged_with_module": "crm",
"mw": false
}