This repository has been archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Read Module Collection By Page
mattkol edited this page Jan 21, 2017
·
2 revisions
This sample usage shows how to read "Contacts" module entity collection data by page. It highlights usage of fields selection option. For more request options make changes to the [Options parameter](Request Options).
This implements the get_entry_list SugarCRM REST API method.
package com.sugaronrest.tests;
import com.sugaronrest.*;
import com.sugaronrest.modules.Leads;
import java.util.List;
import java.util.Map;
String url = "http://demo.suiteondemand.com/service/v4_1/rest.php";
String username = "will";
String password = "will";
SugarRestClient client = new SugarRestClient(url, username, password);
SugarRestRequest request = new SugarRestRequest(Contacts.class, RequestType.PagedRead);
// Select fields.
List<String> selectFields = new ArrayList<String>();
selectFields.add(NameOf.Contacts.FirstName);
// You can mix Java type and json type.
selectFields.add("last_name");
request.getOptions().setSelectFields(selectFields);
// Sets page options
request.getOptions().setCurrentPage(1);
request.getOptions().setNumberPerPage(10);
SugarRestResponse response = client.execute(request);
List<Contacts> cases = (List<Contacts>)response.getData();
List<Contacts> cases = (List<Contacts>)response.getData();
[
{
"last_name": "Thiessen",
"first_name": "Lillian"
},
{
"last_name": "Flanery",
"first_name": "Carmela"
},
{
"last_name": "Bhatt",
"first_name": "Corina"
},
{
"last_name": "Lacross",
"first_name": "Vonda"
},
{
"last_name": "Gram",
"first_name": "Merle"
},
{
"last_name": "Tichenor",
"first_name": "Matilda"
},
{
"last_name": "Bourn",
"first_name": "Polly"
},
{
"last_name": "Moyes",
"first_name": "Janice"
},
{
"last_name": "Lehner",
"first_name": "Ramiro"
},
{
"last_name": "Henriques",
"first_name": "Taylor"
}
]
{
"method": "get_entry_list",
"input_type": "json",
"response_type": "json",
"rest_data": {
"session": "453m6c45til4aqbqr9c8qq24j1",
"module_name": "Contacts",
"query": "",
"order_by": "",
"offset": 0,
"select_fields": [
"first_name",
"last_name"
],
"link_name_to_fields_array": "",
"max_results": 10,
"deleted": 0,
"favorites": false
}
}
{
"total_count": "200",
"relationship_list": [
],
"entry_list": [
{
"name_value_list": {
"last_name": {
"name": "last_name",
"value": "Thiessen"
},
"first_name": {
"name": "first_name",
"value": "Lillian"
}
},
"id": "10f40e9b-d41c-c0e8-1133-587662dd33cc",
"module_name": "Contacts"
},
{
"name_value_list": {
"last_name": {
"name": "last_name",
"value": "Flanery"
},
"first_name": {
"name": "first_name",
"value": "Carmela"
}
},
"id": "1229419e-ac17-7358-e61f-587662248b77",
"module_name": "Contacts"
},
{
"name_value_list": {
"last_name": {
"name": "last_name",
"value": "Bhatt"
},
"first_name": {
"name": "first_name",
"value": "Corina"
}
},
"id": "12485383-7ac5-7b3a-ac76-587662158ce9",
"module_name": "Contacts"
},
{
"name_value_list": {
"last_name": {
"name": "last_name",
"value": "Lacross"
},
"first_name": {
"name": "first_name",
"value": "Vonda"
}
},
"id": "12f7b2c0-fe3f-48a6-6939-587662e795cf",
"module_name": "Contacts"
},
{
"name_value_list": {
"last_name": {
"name": "last_name",
"value": "Gram"
},
"first_name": {
"name": "first_name",
"value": "Merle"
}
},
"id": "15bec6ca-f13e-e360-4f39-58766299d150",
"module_name": "Contacts"
},
{
"name_value_list": {
"last_name": {
"name": "last_name",
"value": "Tichenor"
},
"first_name": {
"name": "first_name",
"value": "Matilda"
}
},
"id": "1689453e-815a-e07d-3aff-587662dfe11e",
"module_name": "Contacts"
},
{
"name_value_list": {
"last_name": {
"name": "last_name",
"value": "Bourn"
},
"first_name": {
"name": "first_name",
"value": "Polly"
}
},
"id": "17cba7b9-7ee1-8cc6-a026-587662fd371f",
"module_name": "Contacts"
},
{
"name_value_list": {
"last_name": {
"name": "last_name",
"value": "Moyes"
},
"first_name": {
"name": "first_name",
"value": "Janice"
}
},
"id": "190c0089-f3ab-e8c9-47dc-587662c23e1f",
"module_name": "Contacts"
},
{
"name_value_list": {
"last_name": {
"name": "last_name",
"value": "Lehner"
},
"first_name": {
"name": "first_name",
"value": "Ramiro"
}
},
"id": "19148e4e-012e-0b39-48e2-587662131ebd",
"module_name": "Contacts"
},
{
"name_value_list": {
"last_name": {
"name": "last_name",
"value": "Henriques"
},
"first_name": {
"name": "first_name",
"value": "Taylor"
}
},
"id": "1c3f0933-7444-aafd-aeca-587662e5c391",
"module_name": "Contacts"
}
],
"result_count": 10,
"next_offset": 10
}
SugarOnRest
- Home
- Request
- Request Types
- Request Options
- Response
- Error Response
- Read Module By Id
- Read Module Collection By Page
- Read Module Collection
- Create Module
- Create Module Collection
- Update Module
- Update Module Collection
- Delete Module
- Linked Modules 1
- Linked Modules 2
- Linked Modules 3
- Query Options 1
- Query Options 2
- Query Options 3