自然言語を使用してページを生成すると、AI によって TypeScript に React ページが作成されます。 生成されたページには、適切なコンポーネントを選択して最適なレイアウトを決定することで、フロントエンド ユーザー エクスペリエンスと、対応するビジネス ロジックの両方が含まれます。
生成されたコードを表示および編集して、出力を絞り込むことができます。 データ操作では、次のパブリック メソッドを公開する dataApi オブジェクトを使用します。
| メソッド | Description |
|---|---|
createRow |
指定したテーブルに新しい行を作成します。 |
updateRow |
指定したテーブル内の既存の行を更新します。 |
deleteRow |
指定したテーブルから行を削除します。 |
retrieveRow |
指定したオプションを持つ指定したテーブルから行を取得します。 |
queryTable |
指定したオプションを使用してテーブルを照会します。 |
getChoices |
指定した選択肢の列名の選択肢を取得します。 |
createRow メソッド
指定したテーブルに新しい行を作成します。
パラメーター
これらの必須パラメーターの値を設定します。
| 名前 | タイプ | Description |
|---|---|---|
tableName |
文字列 | 行を作成するテーブルの論理名。 |
row |
オブジェクト | 作成する行データ。 |
返品ポリシー
操作の結果を含む Promise 。 操作が成功すると、結果は作成された行の ID (Guid) 値になります。
Example
// 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);
}
updateRow メソッド
指定したテーブル内の既存の行を更新します。
パラメーター
これらの必須パラメーターの値を設定します。
| 名前 | タイプ | Description |
|---|---|---|
tableName |
文字列 | 行を更新するテーブルの論理名。 |
rowId |
文字列 | 更新する行の ID。 |
row |
Object | 更新する行データ。 |
返品ポリシー
操作の結果を含む Promise 。 操作が成功すると、値は返されません。
Example
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);
}
deleteRow メソッド
指定したテーブルから行を削除します。
パラメーター
これらの必須パラメーターの値を設定します。
| 名前 | タイプ | Description |
|---|---|---|
tableName |
文字列 | 行を削除するテーブルの論理名。 |
rowId |
文字列 | 削除する行の ID。 |
返品ポリシー
操作の結果を含む Promise 。 操作が成功すると、値は返されません。
Example
let rowId = "5531d753-95af-e711-a94e-000d3a11e605";
try {
await dataApi.deleteRow("account", rowId);
}
catch (error) {
console.log(error.message);
}
retrieveRow メソッド
指定したオプションを使用して、指定したテーブルから行を取得します。
パラメーター
これらの必須パラメーターの値を設定します。
| 名前 | タイプ | Description |
|---|---|---|
tableName |
string |
取得元のテーブルの論理名 |
options |
RetrieveRowOptions | 行を取得するためのオプション |
RetrieveRowOptions
| 名前 | タイプ | Description |
|---|---|---|
id |
string |
取得する行の ID (Guid) |
select |
string[] |
(推奨)取得する列名の配列。 省略すると、すべての列が返されます。 |
返品ポリシー
操作の結果を含む Promise 。 操作が成功すると、選択したすべての列を含む、レコードのデータを含むオブジェクトが返されます。
Example
// 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'],
});
queryTable メソッド
指定したオプションを使用してテーブルを照会します。
パラメーター
これらの必須パラメーターの値を設定します。
| 名前 | タイプ | Description |
|---|---|---|
tableName |
string |
クエリを実行するテーブルの論理名 |
query |
QueryTableOptions | テーブルに対してクエリを実行するためのオプション |
QueryTableOptions
| 名前 | タイプ | Description |
|---|---|---|
select |
string[] |
(推奨)取得する列名の配列。 |
filter |
string |
(省略可能)OData フィルター式 (たとえば、 statecode eq 0)。 |
orderBy |
string |
(省略可能)OData orderby 式 (たとえば、 name asc、 createdon desc)。 |
pageSize |
number |
(省略可能)ページごとに返される行の最大数。 |
返品ポリシー
操作の結果を含む Promise 。 操作が成功すると、promise は次のプロパティを持つ結果を含むデータ テーブルを含むオブジェクトを返します。
| 名前 | タイプ | Description |
|---|---|---|
rows |
Object[] |
行データの配列 |
hasMoreRows |
boolean |
使用可能な行が増えるかどうかを示します |
loadMoreRows |
function |
結果の次のページを読み込む関数。 (省略可能) |
Example
// 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`);
}
注釈
注
パフォーマンスを最大限に高めるには、 QueryTableOptionsselect プロパティを使用して返される列の数を常に制限してください。
getChoices メソッド
指定した選択肢の列名の選択肢を取得します。
パラメーター
このパラメーターは必須です。
| 名前 | タイプ | Description |
|---|---|---|
enumName |
string |
形式の選択肢列の名前 tablename-columnname |
返品ポリシー
操作の結果を含む Promise 。 操作が成功すると、選択オプションの配列が返されます。 各オプションには、次のプロパティがあります。
| 名前 | タイプ | Description |
|---|---|---|
label |
文字列 | オプションのローカライズされたラベル値。 |
value |
数値 | オプションの数値。 |
Example
// 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');