Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Gunakan metode dataApi tabel objek untuk membuat, mengambil, memperbarui, dan menghapus baris tabel Dataverse, dan kolom pilihan kueri.
| Metode | Description |
|---|---|
createRow |
Membuat baris baru dalam tabel yang ditentukan. |
deleteRow |
Menghapus baris dari tabel yang ditentukan. |
getChoices |
Mengambil pilihan untuk nama kolom pilihan yang ditentukan. |
queryTable |
Mengkueri tabel dengan opsi yang ditentukan. |
retrieveRow |
Mengambil baris dari tabel yang ditentukan dengan opsi yang ditentukan. |
updateRow |
Memperbarui baris yang sudah ada dalam tabel yang ditentukan. |
metode createRow
Membuat baris baru dalam tabel yang ditentukan.
Parameters
Atur nilai untuk parameter yang diperlukan ini.
| Name | Type | Description |
|---|---|---|
tableName |
string | Nama logis tabel untuk membuat baris. |
row |
objek | Data baris yang akan dibuat. |
Returns
Janji yang berisi hasil operasi. Ketika operasi berhasil, hasilnya adalah nilai ID (Guid) dari baris yang dibuat.
contoh createRow
// Define the row data to create new account
var row =
{
"name": "Sample Account",
"creditonhold": false,
"address1_latitude": 47.639583,
"description": "This is the description of the sample account",
"revenue": 5000000,
"accountcategorycode": 1,
}
try {
// Create a new account record
const newAccountId = await dataApi.createRow("account", row);
console.log("Account created with ID: " + newAccountId);
// Create a contact with a lookup to an account
const newContactId = await dataApi.createRow('contact', {
firstname: 'John',
lastname: 'Doe',
emailaddress1: 'john.doe@contoso.com',
"parentcustomerid@odata.bind": `/account(${newAccountId})`, // Lookup format
});
}
catch (error) {
console.log(error.message);
}
metode deleteRow
Menghapus baris dari tabel yang ditentukan.
Parameters
Atur nilai untuk parameter yang diperlukan ini.
| Name | Type | Description |
|---|---|---|
tableName |
string | Nama logis tabel untuk menghapus baris. |
rowId |
string | ID baris yang akan dihapus. |
Returns
Janji yang berisi hasil operasi. Ketika operasi berhasil, operasi tidak mengembalikan nilai.
contoh deleteRow
let rowId = "5531d753-95af-e711-a94e-000d3a11e605";
try {
await dataApi.deleteRow("account", rowId);
}
catch (error) {
console.log(error.message);
}
metode getChoices
Mengambil pilihan untuk nama kolom pilihan yang ditentukan.
Parameters
Parameter ini diperlukan.
| Name | Type | Description |
|---|---|---|
enumName |
string |
Nama kolom pilihan dalam format tablename-columnname |
Returns
Janji yang berisi hasil operasi. Ketika operasi berhasil, operasi mengembalikan array opsi pilihan. Setiap opsi memiliki properti ini:
| Name | Type | Description |
|---|---|---|
label |
string | Nilai label yang dilokalkan dari opsi . |
value |
number | Nilai numerik opsi. |
contoh getChoices
// Returns the accountcategorycode column options from the account table
const categoryChoices = await dataApi.getChoices("account-accountcategorycode");
// Returns the statecode column options from the contact table
const stateChoices = await dataApi.getChoices('contact-statecode');
// Returns the statuscode column options from the account table
const statusChoices = await dataApi.getChoices('account-statuscode');
metode queryTable
Mengkueri tabel dengan menggunakan opsi yang ditentukan.
Parameters
Atur nilai untuk parameter yang diperlukan ini.
| Name | Type | Description |
|---|---|---|
tableName |
string |
Nama logis tabel yang akan dikueri |
query |
QueryTableOptions | Opsi untuk mengkueri tabel |
QueryTableOptions
| Name | Type | Description |
|---|---|---|
select |
string[] |
(Disarankan) Array nama kolom yang akan diambil. |
filter |
string |
(Opsional) Ekspresi filter OData (misalnya, statecode eq 0). |
orderBy |
string |
(Opsional) Ekspresi orderby OData (misalnya, name asc, createdon desc). |
pageSize |
number |
(Opsional) Jumlah maksimum baris yang akan dikembalikan per halaman. |
Returns
Janji yang berisi hasil operasi. Ketika operasi berhasil, janji mengembalikan objek yang berisi tabel data dengan hasil dengan properti ini:
| Name | Type | Description |
|---|---|---|
rows |
Object[] |
Array data baris |
hasMoreRows |
boolean |
Menunjukkan apakah ada lebih banyak baris yang tersedia |
loadMoreRows |
function |
Fungsi untuk memuat halaman hasil berikutnya. (Opsional) |
contoh queryTable
// Query tasks with options
const result = await dataApi.queryTable("task", {
select: ["activityid", "subject", "scheduledend", "prioritycode", "statecode"],
orderBy: "scheduledend asc",
pageSize: 50,
filter: "statecode eq 0"
});
// Query accounts with pagination
const pagedAccounts = await dataApi.queryTable('account', {
select: ['name'],
pageSize: 50,
});
console.log(`Page 1: ${pagedAccounts.rows.length} accounts`);
if (pagedAccounts.hasMoreRows && pagedAccounts.loadMoreRows) {
const nextPage = await pagedAccounts.loadMoreRows();
console.log(`Page 2: ${nextPage.rows.length} accounts`);
}
Remarks
Note
Untuk performa terbaik, selalu batasi jumlah kolom yang dikembalikan dengan menggunakan properti QueryTableOptionsselect .
metode retrieveRow
Mengambil baris dari tabel yang ditentukan dengan menggunakan opsi yang ditentukan.
Parameters
Atur nilai untuk parameter yang diperlukan ini.
| Name | Type | Description |
|---|---|---|
tableName |
string |
Nama logis tabel yang akan diambil |
options |
RetrieveRowOptions | Opsi untuk mengambil baris |
RetrieveRowOptions
| Name | Type | Description |
|---|---|---|
id |
string |
ID (Guid) baris yang akan diambil |
select |
string[] |
(Disarankan) Array nama kolom yang akan diambil. Jika dihilangkan, semua kolom dikembalikan. |
Returns
Janji yang berisi hasil operasi. Saat operasi berhasil, operasi mengembalikan objek dengan data rekaman, termasuk semua kolom yang dipilih.
contoh retrieveRow
// Retrieve an account with all columns
const account = await dataApi.retrieveRow('account', {
id: '30dc51e9-947d-47d8-ad48-4fc48fba4a95',
});
// Retrieve specific columns only
const contact = await dataApi.retrieveRow('contact', {
id: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
select: ['firstname', 'lastname', '_parentcustomerid_value'],
});
metode updateRow
Memperbarui baris yang sudah ada dalam tabel yang ditentukan.
Parameters
Atur nilai untuk parameter yang diperlukan ini.
| Name | Type | Description |
|---|---|---|
tableName |
string | Nama logis tabel untuk memperbarui baris. |
rowId |
string | ID baris yang akan diperbarui. |
row |
Object | Data baris yang akan diperbarui. |
Returns
Janji yang berisi hasil operasi. Ketika operasi berhasil, operasi tidak mengembalikan nilai.
contoh updateRow
let rowId = "5531d753-95af-e711-a94e-000d3a11e605"
// Define the row to update a record
var row =
{
"name": "Updated Sample Account ",
"creditonhold": true,
"address1_latitude": 47.639583,
"description": "This is the updated description of the sample account",
"revenue": 6000000,
"accountcategorycode": 2
}
// update the record
try {
await dataApi.updateRow("account", rowId, row);
}
catch (error){
console.log(error.message);
}