Modifier and Type | Method and Description |
---|---|
BatchOperation<PositionalRecordId,BatchOperationError> |
batchDeleteRecords(List<Record> records)
Creates an operation which can be used to delete the specified List of Records.
|
BatchOperation<PositionalRecordId,BatchOperationError> |
batchSaveRecords(List<Record> records)
Creates an operation to save the specified List of records.
|
DeleteRecordsResponse |
deleteRecords(List<Record> records)
Deprecated.
as of 17R2.2, replaced by
batchDeleteRecords(List) |
Record |
newRecord(String objectName)
Instantiates a
Record of the specified type but does not set the id . |
Record |
newRecordWithId(String objectName,
String recordId)
Instantiates a
Record of the specified type and sets the id . |
ReadRecordsResponse |
readRecords(List<Record> records)
Retrieves the requested Record with all fields and values inside the current transaction.
|
SaveRecordsResponse |
saveRecords(List<Record> records)
Deprecated.
as of 17R2.2, replaced by
batchSaveRecords(List) |
Record newRecord(String objectName)
Record
of the specified type but does not set the id
.
Note this is not a persistence operation. It merely creates a data-holder for Record values. You will need to set the values for fields on this Record.
objectName
- name of a Vault object (for example, country__v
).Record newRecordWithId(String objectName, String recordId)
Record
of the specified type and sets the id
.
Use this method to create an instance of an existing record for reading, updating, or deleting.
This method does everything that newRecord(String)
does and additionally sets the id
value to an existing recordId
.
objectName
- name of a Vault object, for example, country__v
recordId
- id of an existing record, for example, 00C000000101SaveRecordsResponse saveRecords(List<Record> records)
batchSaveRecords(List)
A "save" can be either an insert or update. If an input Record
has no id
, that's
an indication the record should be created. If the input Record
has an id
, that's
an indication the record should be updated.
This saves the record(s) regardless of the current user's access to that record. Security is not enforced by default.
This is not an all-or-nothing operation. It will save what it can and ignore what it cannot. The returned result must be interrogated if the caller needs to know whether a particular record was or wasn't saved.
All records in the input List must be of the same type, such as Record.getObjectName()
, otherwise
a runtime exception will be thrown.
records
- List of records to saveSaveRecordsResponse
for more information.BatchOperation<PositionalRecordId,BatchOperationError> batchSaveRecords(List<Record> records)
A "save" can be either an insert or update. If an input Record
has no id
, that's
an indication that the record should be created. If the input Record
has an id
, that's
an indication that the record should be updated.
The returned operation saves all specified records, regardless of the current user's access to those records.
The way errors and successes are handled can
be specified on the returned BatchOperation
. Once success-handling and
error-handling is specified, you can call BatchOperation.execute()
to execute the save. For example:
recordService.batchSaveRecords(records).rollbackOnErrors().execute()
All records in the input List must be of the same type (Record.getObjectName()
) and cannot exceed 500 records.
records
- List of records to save. The only information used from the input records are the object name
and id
.ReadRecordsResponse readRecords(List<Record> records)
For example, trigger X updates the name
field on a record from "Bob" to "Carl", and also initiates
nested trigger Y. Trigger Y wants to take the name
value of the current record and check it against a
current List of patients.
If you use ReadRecordsResponse
within Y, you will retrieve the new value of "Carl" for the name
value,
even though the transaction has not yet finished and the record is not yet saved with the new value.
If you use QueryService
within Y, you will retrieve "Bob" for the name
value because the new value of "Carl" is not yet saved.
Best practice dictates the use of QueryService
to query the specific field you need,
unless you need the value inside of the transaction.
All records in the input List must be of the same type (Record.getObjectName()
) and cannot exceed 500 records.
records
- List of Records to read. Invalid Record ids are ignored.ReadRecordsResponse
for more information.DeleteRecordsResponse deleteRecords(List<Record> records)
batchDeleteRecords(List)
This deletes records regardless of the current user's access to that record. Security is not enforced by default.
This is not an all-or-nothing operation. It will delete what it can and ignore what it cannot. The returned result must be interrogated if the caller needs to know whether a particular record was or wasn't deleted.
All records in the input List must be of the same type, such as Record.getObjectName()
and cannot exceed 500 records.
records
- the records to delete. The only information from the record will be the objectName and the id.DeleteRecordsResponse
for more information.BatchOperation<PositionalRecordId,BatchOperationError> batchDeleteRecords(List<Record> records)
This deletes the Record(s) regardless of the current user's access to that record. In other words, security is not enforced.
The way that errors and successes are handled can
be specified on the returned BatchOperation
. And then when success and
error-handling have been specified, the method BatchOperation.execute()
should be called to finally execute the delete. Here's an example:
recordService.batchDeleteRecords(records).rollbackOnErrors().execute()
All Records in the input List must be of the same type, such as Record.getObjectName()
and cannot exceed 500 records.
records
- the Records to delete. The only information used from the input Records are the object name
and id
.Copyright © Veeva Systems 2017–2021. All rights reserved.