개체의 테이블 메서드를 dataApi 사용하여 Dataverse 테이블 행 및 쿼리 선택 열을 만들고, 검색하고, 업데이트하고, 삭제합니다.
| 메서드 | Description |
|---|---|
createRow |
지정된 테이블에 새 행을 만듭니다. |
deleteRow |
지정된 테이블에서 행을 삭제합니다. |
getChoices |
지정된 선택 열 이름에 대한 선택 항목을 검색합니다. |
queryTable |
지정된 옵션을 사용하여 테이블을 쿼리합니다. |
retrieveRow |
지정된 옵션을 사용하여 지정된 테이블에서 행을 검색합니다. |
updateRow |
지정된 테이블의 기존 행을 업데이트합니다. |
createRow 메서드
지정된 테이블에 새 행을 만듭니다.
Parameters
이러한 필수 매개 변수에 대한 값을 설정합니다.
| Name | Type | Description |
|---|---|---|
tableName |
string | 행을 만들 테이블의 논리적 이름입니다. |
row |
object | 만들 행 데이터입니다. |
Returns
작업 결과를 포함하는 프라미스 입니다. 작업이 성공하면 생성된 행의 ID(Guid) 값이 생성됩니다.
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);
}
deleteRow 메서드
지정된 테이블에서 행을 삭제합니다.
Parameters
이러한 필수 매개 변수에 대한 값을 설정합니다.
| Name | Type | Description |
|---|---|---|
tableName |
string | 행을 삭제할 테이블의 논리적 이름입니다. |
rowId |
string | 삭제할 행의 ID입니다. |
Returns
작업 결과를 포함하는 프라미스 입니다. 작업이 성공하면 값을 반환하지 않습니다.
deleteRow 예제
let rowId = "5531d753-95af-e711-a94e-000d3a11e605";
try {
await dataApi.deleteRow("account", rowId);
}
catch (error) {
console.log(error.message);
}
getChoices 메서드
지정된 선택 열 이름에 대한 선택 항목을 검색합니다.
Parameters
이 매개 변수는 필수입니다.
| Name | Type | Description |
|---|---|---|
enumName |
string |
형식의 선택 열 이름 tablename-columnname |
Returns
작업 결과를 포함하는 프라미스 입니다. 작업이 성공하면 선택 옵션의 배열을 반환합니다. 각 옵션에는 다음과 같은 속성이 있습니다.
| Name | Type | Description |
|---|---|---|
label |
string | 옵션의 지역화된 레이블 값입니다. |
value |
number | 옵션의 숫자 값입니다. |
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');
queryTable 메서드
지정된 옵션을 사용하여 테이블을 쿼리합니다.
Parameters
이러한 필수 매개 변수에 대한 값을 설정합니다.
| Name | Type | Description |
|---|---|---|
tableName |
string |
쿼리할 테이블의 논리적 이름 |
query |
QueryTableOptions | 테이블 쿼리 옵션 |
QueryTableOptions
| Name | Type | Description |
|---|---|---|
select |
string[] |
(권장) 검색할 열 이름의 배열입니다. |
filter |
string |
(선택 사항) OData 필터 식(예: statecode eq 0). |
orderBy |
string |
(선택 사항) OData orderby 식(예: name asc, createdon desc). |
pageSize |
number |
(선택 사항) 페이지당 반환할 최대 행 수입니다. |
Returns
작업 결과를 포함하는 프라미스 입니다. 작업이 성공하면 promise는 다음과 같은 속성이 포함된 결과가 포함된 데이터 테이블이 포함된 개체를 반환합니다.
| Name | Type | Description |
|---|---|---|
rows |
Object[] |
행 데이터 배열 |
hasMoreRows |
boolean |
사용할 수 있는 행이 더 있는지를 나타냅니다. |
loadMoreRows |
function |
결과의 다음 페이지를 로드하는 함수입니다. (선택 사항) |
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
비고
최상의 성능을 위해 항상 QueryTableOptions 속성을 사용하여 반환되는 열 수를 제한합니다select.
retrieveRow 메서드
지정된 옵션을 사용하여 지정된 테이블에서 행을 검색합니다.
Parameters
이러한 필수 매개 변수에 대한 값을 설정합니다.
| Name | Type | Description |
|---|---|---|
tableName |
string |
검색할 테이블의 논리적 이름 |
options |
RetrieveRowOptions | 행 검색 옵션 |
RetrieveRowOptions
| Name | Type | Description |
|---|---|---|
id |
string |
검색할 행의 ID(Guid) |
select |
string[] |
(권장) 검색할 열 이름의 배열입니다. 생략하면 모든 열이 반환됩니다. |
Returns
작업 결과를 포함하는 프라미스 입니다. 작업이 성공하면 선택한 모든 열을 포함하여 레코드 데이터가 있는 개체를 반환합니다.
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'],
});
updateRow 메서드
지정된 테이블의 기존 행을 업데이트합니다.
Parameters
이러한 필수 매개 변수에 대한 값을 설정합니다.
| Name | Type | Description |
|---|---|---|
tableName |
string | 행을 업데이트할 테이블의 논리적 이름입니다. |
rowId |
string | 업데이트할 행의 ID입니다. |
row |
Object | 업데이트할 행 데이터입니다. |
Returns
작업 결과를 포함하는 프라미스 입니다. 작업이 성공하면 값을 반환하지 않습니다.
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);
}