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
Update Module Collection
mattkol edited this page Jan 21, 2017
·
2 revisions
This sample usage shows how to update "Leads" module entity collection data. For more request options make changes to the [Options parameter](Request Options).
This implements the set_entries 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("Leads", RequestType.BulkRead);
request.getOptions().setMaxResult(3);
SugarRestResponse leadsReadResponse = client.execute(request);
List<Leads> leadsToUpdate = (List<Leads>) leadsReadResponse.getData();
request = new SugarRestRequest(Leads.class, RequestType.BulkUpdate);
// Update account description
for (Leads lead : leadsToUpdate)
{
lead.setAccountDescription("Lead Account moved on Jan 20, 2017.");
}
request.setParameter(leadsToUpdate);
// Select fields.
List<String> selectFields = new ArrayList<String>();
selectFields.add(NameOf.Leads.AccountName);
selectFields.add(NameOf.Leads.AccountDescription);
selectFields.add(NameOf.Leads.Status);
request.getOptions().setSelectFields(selectFields);
SugarRestResponse response = client.execute(request);
List<String> updatedLeadIds = (List<String>)response.getData();
[
"10a5aca7-a94b-c84a-d01a-587662da31cd",
"118f5999-4e81-5510-8c00-587662372d02",
"1304e89b-942b-5866-2aad-587662f632d5"
]
{
"method": "set_entries",
"input_type": "json",
"response_type": "json",
"rest_data": {
"session": "91613h1ih8cjgq29nchmgkpf53",
"module_name": "Leads",
"name_value_list": [
{
"account_description": {
"name": "account_description",
"value": "Lead Account moved on Jan 20, 2017."
},
"account_name": {
"name": "account_name",
"value": "Sandeon Consolidation Corp"
},
"id": {
"name": "id",
"value": "10a5aca7-a94b-c84a-d01a-587662da31cd"
},
"status": {
"name": "status",
"value": "New"
}
},
{
"account_description": {
"name": "account_description",
"value": "Lead Account moved on Jan 20, 2017."
},
"account_name": {
"name": "account_name",
"value": "Spindle Broadcast Corp."
},
"id": {
"name": "id",
"value": "118f5999-4e81-5510-8c00-587662372d02"
},
"status": {
"name": "status",
"value": "New"
}
},
{
"account_description": {
"name": "account_description",
"value": "Lead Account moved on Jan 20, 2017."
},
"account_name": {
"name": "account_name",
"value": "Airline Maintenance Co"
},
"id": {
"name": "id",
"value": "1304e89b-942b-5866-2aad-587662f632d5"
},
"status": {
"name": "status",
"value": "Dead"
}
}
]
}
}
{
"ids": [
"10a5aca7-a94b-c84a-d01a-587662da31cd",
"118f5999-4e81-5510-8c00-587662372d02",
"1304e89b-942b-5866-2aad-587662f632d5"
]
}
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