Skip to main content

Index

One of the primary calls of FIYGE is the GET /index. This returns a list of records of the requested controller.

For example, the following request will return all leads the user has access to.

Request​

GET /crm/leads/index.json

Request Success​

{
"paginate": {
"data": [
{
"leads.name": "Test LEAD 1",
"Type": "Internal Staff",
"Sub Type": "Active",
"config_lead_sources.lead_source": "B2B Partner - RCIC",
"Current Stage": "04 Meeting to Finalize Product & Price - In Progress",
"Current Workflow Actors": "Michael Ilao",
"leads.primary_email": "michael@fiyge.com",
"Created By": "Michael Ilao",
"Owned By": "Michael Ilao",
"leads.created": "2025-01-03 09:32:07",
"leads.id": "1811",
"leads._acl_comment": null,
"leads._acl_edit": " u739",
"leads._acl_tmp_edit": null,
"leads._acl_delete": null,
"leads._acl_tmp_delete": null,
"leads.deleted": "0",
"record_display_name": "Test LEAD 1",
"is_edit": true,
"is_delete": false,
"is_comment": false
}
],
"alias": "leads",
"count_query": {},
"query": {},
"render_as": "index",
"page": 1,
"page_size": 25,
"total_count": 26,
"primary_key": "leads.id",
"display_field": "leads.name",
"name": "All Leads",
"category_id": "5",
"category_id_model": "listview_categories",
"__category_id": "Business Views",
"header":[],
"listview_id": "535a2baf-ea04-48db-b4ef-153d0af91b9d"
},
"errors": [],
"current_listview": "535a2baf-ea04-48db-b4ef-153d0af91b9d",
"__current_listview": "All Leads",
"listview_id": "535a2baf-ea04-48db-b4ef-153d0af91b9d",
"listview_name": "All Leads",
}

The request contains a list of leads, as well as the meta data about the request. Inside paginate.data, is an array of the leads requested. The fields within each element are dictiated by the controller (leads) as well as the listview_id (535a2baf-ea04-48db-b4ef-153d0af91b9d).

On each element are a set of consistent flags is_edit, is_delete and is_comment. These flags tell the permission the user has on the record. For example the user can edit Test LEAD 1, but not delete or comment on the record.

Listviews​

Listviews in FIYGE are preconfigured lists that display data in different format based on a set of filters and fields. For example a view could return Leads this Week or Leads Lost. To fetch a view all we need to do is append the listview_id to the request as a paramater of current_listview. When accessing the default endpoint without a view set, it will return the default view or the view last accessed by this user.

https://v2.crm.immigrate.fiyge.com/crm/leads/index?current_listview=52611fb5-6ca8-4815-96d7-1d890acef1b9

In this case we are fetching listview_id=52611fb5-6ca8-4815-96d7-1d890acef1b9 to get Leads this Week.

To get the list of available Listviews for a given controller a request must be made first to core/listviews/index.json.

Request to fetch listviews​

GET https://v2.crm.immigrate.fiyge.com/core/listviews/index.json?q=
{
"fields": [
"listviews.id",
"listviews.name",
"listviews.controller",
"category.name as category_name",
"listviews.is_default"
],
"where":[
{
"listviews.controller":"crm/leads"
}
],
"order":[
"category.sequence ASC",
"listviews.sequence ASC"
],
"method":"find"
}
Authorization: Bearer <your_token>

The q params allows us to query data on the fly, by passing a json object for the fields, where conditions, and order for the requested data (Similar to SQL statements).

In this case we are requesting the fields:

  • id
  • name as category_name (alias)
  • controller
  • is_default

We are querying data that matches the where condition of

controller == "crm/leads"

And are order by the sequence of the category associated to the view then by the listview itself.

The following is a code snippet to create this URL in javascript

const searchParams = {
fields: [
"listviews.id",
"listviews.name",
"listviews.controller",
"category.name as category_name",
"listviews.is_default",
],
where: [
{
"listviews.controller": "crm/leads",
},
],
order: ["category.sequence ASC", "listviews.sequence ASC"],
method: "find",
};

const encodedQueryString = encodeURIComponent(JSON.stringify(searchParams));
url.searchParams.append("q", encodedQueryString);
const fetchOptions = {
headers: {
Authorization: `Bearer ${accessToken}`
}
};
const listViewResponse = await fetch(url.toString(), fetchOptions);

Listview Response​

{
"paginate": {
"headers": [],
"data": [
{
"id": "535a2baf-ea04-48db-b4ef-153d0af91b9d",
"name": "All Leads",
"controller": "crm/leads",
"category_name": "Business Views",
"is_default": "1",
"_acl_comment": " u655 g2630",
"_acl_edit": " u-1 u655 g2630",
"_acl_tmp_edit": null,
"_acl_delete": " u-1 u655 g2630",
"_acl_tmp_delete": null
},
]
}
}

Now with a list of views we can use the id to fetch a specific view on our /index request

Headers​

Included with the data is the headers, that provides meta-data about the columns returned, that can be used to build a table.

{
"data": {},
"headers": [
{
"field_type": "Data-Field",
"sortable": true,
"searchable": true,
"is_invisible": "0",
"clickable_link": "0",
"compute_column_total": "0",
"column_name": "leads.name",
"name": "leads.name",
"data_type": "VAR_STRING",
"visible": 1,
"column_total": 0,
"total_count": 0,
"label": "Name"
},
{
"field_type": "Data-Field",
"alias": "Type",
"sortable": true,
"searchable": true,
"is_invisible": "0",
"clickable_link": "0",
"compute_column_total": "0",
"column_name": "leads.config_people_types.people_type",
"name": "Type",
"data_type": "VAR_STRING",
"visible": 1,
"column_total": 0,
"total_count": 0,
"label": "Type"
},
],
}
  • field_type: If the field is a data field or if it is a computed value
  • sortable: flag to allow sorting
  • searchable: flag to allow searching
  • column_name: name of the data column
  • name: name of the field
  • data_type: type of the field
  • visible: flag to show to column or not
  • label: string to display as the label

Query Paramaters​

Used in default /index calls

  • current_listview: to select the current list view
  • page: pagination, note: starts at 1
  • limit: how many records to fetch
  • sort: what column to sort on, column_name from header
  • dir: sort direction DESC or ASC
  • search_basic: string to search on, searches all columns

Used in /view and /edit calls

  • related_to: fetch records related to a specific id. ex: 1811
  • current_category: used to fetch all records. ex: System View
  • search_criteria: used to fetch all records. 0
  • q: query params for specific and fine grain filtering

q Paramaters​

For fetching on a list with specific queries, fetching records where the url is /crm/leads/index, and type controller and returning all the fields of the records.

q = {
"method": "find",
"fields": [
"*"
],
"where": {
"url": "crm/leads/index",
"type": "controller"
}
}

For fetching related records to a specific id, this case we are fetching related records to the leads with a primary key 1811.

q = {
"where": {
"{{FOREIGN}}.{{FOREIGN_PRIMARY_KEY}}": "1811"
},
"pheader": "0",
"related_model_class": "\\module\\crm\\model\\leads",
"show_has_many_records": "all"
}

Chart & Graphs​

FIYGE supports multiple views of data, some of the following are.

  • Line Chart
  • Pie Chart
  • Bar Chart
  • Guage Chart
  • Geo Chart
  • ...

When fetching the views there is a field query that contains a string JSON, that when parsed using JSON.parse contains a field ui_helper.

{
"ui_helper":"\\\\module\\\\core\\\\helper\\\\data_view\\\\graph::pie_chart"
}

This flag indictates which graph to use to display.